Skip to content

Commit d7b08a5

Browse files
committed
Fix code snippets and enhance metadata retrieval documentation
Updated code snippets in README for header retrieval and added optional parameter documentation details. Also fixed some CI formatting errors.
1 parent 0c957a9 commit d7b08a5

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

CCDB/README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ in circumstances of reduced or no network connectivity.
1313

1414
There are currently 2 different kinds of store/retrieve functions, which we expect to unify in the immediate future:
1515
2. `storeAsTFile/retrieveFromTFile` API serializing a `TObject` in a ROOT `TFile`.
16-
3. A strongly-typed `storeAsTFileAny<T>/retrieveFromTFileAny<T>` API allowing to handle any type T
16+
3. A strongly-typed `storeAsTFileAny<T>/retrieveFromTFileAny<T>` API allowing to handle any type T
1717
having a ROOT dictionary. We encourage to use this API by default.
1818

1919
## Central and local instances of the CCDB
@@ -37,12 +37,12 @@ api.init("http://ccdb-test.cern.ch:8080"); // or http://localhost:8080 for a loc
3737
auto deadpixels = new o2::FOO::DeadPixelMap();
3838
api.storeAsTFileAny(deadpixels, "FOO/DeadPixels", metadata);
3939
// read like this (you have to specify the type)
40-
auto deadpixelsback = api.retrieveFromTFileAny<o2::FOO::DeadPixelMap>("FOO/DeadPixels", metadata);
41-
// read like this to get the headers as well, and thus the metadata attached to the object
40+
auto deadpixelsback = api.retrieveFromTFileAny<o2::FOO::DeadPixelMap>("FOO/DeadPixels", metadata);
41+
// read like this to get the headers as well, and thus the metadata attached to the object
4242
std::map<std::string, std::string> headers;
43-
auto deadpixelsback = api.retrieveFromTFileAny<o2::FOO::DeadPixelMap>("FOO/DeadPixels", metadata /* constraint the objects retrieved to those matching the metadata */, -1 /* timestamp */, &headers /* the headers attached to the returned object */);
43+
auto deadpixelsback = api.retrieveFromTFileAny<o2::FOO::DeadPixelMap>("FOO/DeadPixels", metadata /* constraint the objects retrieved to those matching the metadata */, -1 /* timestamp */, &headers /* the headers attached to the returned object */);
4444
// finally, use this method to retrieve only the headers (and thus the metadata)
45-
std::map<std::string, std::string> headers = f.api.retrieveHeaders("FOO/DeadPixels", f.metadata);
45+
std::map<std::string, std::string> headers = api.retrieveHeaders("FOO/DeadPixels", metadata);
4646
```
4747

4848
* creating a local snapshot and fetching objects therefrom
@@ -85,7 +85,7 @@ user code. This class
8585
The class was written for the use-case of transport MC simulation. Typical usage should be like
8686

8787
```c++
88-
// setup manager once (at start of processing)
88+
// setup manager once (at start of processing)
8989
auto& mgr = o2::ccdb::BasicCCDBManager::instance();
9090
mgr.setURL("http://ourccdbserverver.cern.ch");
9191
mgr.setTimestamp(timestamp_which_we_want_to_anchor_to);
@@ -111,6 +111,12 @@ This feature is useful to avoid using newer objects if the CCDB is updated in pa
111111

112112
In cached mode, the manager can check that local objects are still valid by requiring `mgr.setLocalObjectValidityChecking(true)`, in this case a CCDB query is performed only if the cached object is no longer valid.
113113

114+
If you want the headers/metadata for the object retrieved from the CCDB there is an optional paramater to `BasicCCDBManager::getForTimeStamp`. These headers are also cached (when caching is enabled) and is updated when a CCDB query is sent.
115+
```c++
116+
std::map<std::string,std::string> headers;
117+
mgr.getForTimeStamp(path, timstamp, metadata, &headers);
118+
```
119+
114120
## Future ideas / todo:
115121

116122
- [ ] offer improved error handling / exceptions
@@ -129,26 +135,26 @@ A few prototypic command line tools are offered. These can be used in scriptable
129135
and facilitate the following tasks:
130136

131137
1. Upload and annotate a generic C++ object serialized in a ROOT file
132-
138+
133139
```bash
134140
o2-ccdb-upload -f myRootFile.root --key histogram1 --path /Detector1/QA/ --meta "Description=Foo;Author=Person1;Uploader=Person2"
135141
```
136142
This will upload the object serialized in `myRootFile.root` under the key `histogram1`. Object will be put to the CCDB path `/Detector1/QA`.
137143
For full list of options see `o2-ccdb-upload --help`.
138-
144+
139145
2. Download a CCDB object to a local ROOT file (including its meta information)
140-
146+
141147
```bash
142148
o2-ccdb-downloadccdbfile --path /Detector1/QA/ --dest /tmp/CCDB --timestamp xxx
143149
```
144150
This will download the CCDB object under path given by `--path` to a directory given by `--dest` on the disc.
145151
(The final filename will be `/tmp/CCDB/Detector1/QA/snapshot.root` for the moment).
146152
All meta-information as well as the information associated to this query will be appended to the file.
147-
153+
148154
For full list of options see `o2-ccdb-downloadccdbfile --help`.
149-
155+
150156
3. Inspect the content of a ROOT file and print summary about type of contained (CCDB) objects and its meta information
151-
157+
152158
```bash
153159
o2-ccdb-inspectccdbfile filename
154160
```

CCDB/test/testCcdbApiHeaders.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ struct Fixture {
4040
Fixture()
4141
{
4242
o2::ccdb::CcdbApi api;
43-
if (std::getenv("ALICEO2_CCDB_HOST"))
43+
if (std::getenv("ALICEO2_CCDB_HOST")) {
4444
ccdbUrl = std::string(std::getenv("ALICEO2_CCDB_HOST"));
45+
}
4546
api.init(ccdbUrl);
4647
hostReachable = api.isHostReachable();
4748
char hostname[_POSIX_HOST_NAME_MAX];

0 commit comments

Comments
 (0)