Skip to content

Commit a0d84eb

Browse files
authored
Merge branch 'dev' into merge-noise-branch
2 parents 6b638a1 + 5a7fba3 commit a0d84eb

File tree

2,354 files changed

+124233
-56261
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,354 files changed

+124233
-56261
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Apply requested async label
3+
4+
'on':
5+
issue_comment:
6+
types:
7+
- created
8+
- edited
9+
10+
permissions: {}
11+
12+
jobs:
13+
apply_async_labels:
14+
name: Apply requested async label
15+
uses: alisw/ali-bot/.github/workflows/async-auto-label.yml@master
16+
permissions:
17+
pull-requests: write # to update labels
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Collect and print async labels
3+
4+
'on':
5+
pull_request_target:
6+
types:
7+
- opened
8+
- reopened
9+
branches:
10+
- dev
11+
12+
permissions: {}
13+
14+
jobs:
15+
list_async_labels:
16+
name: Collect and print async labels
17+
uses: alisw/ali-bot/.github/workflows/async-list-label.yml@master
18+
permissions:
19+
pull-requests: write # to update labels

.github/workflows/clean-test.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ name: Clean PR checks
4343
description: build/O2/o2-dataflow-cs8
4444
type: boolean
4545
default: true
46+
'check_build/O2/o2/aarch64':
47+
description: build/O2/o2/aarch64
48+
type: boolean
49+
default: true
50+
'check_build/O2/o2_slc9':
51+
description: build/O2/o2_slc9
52+
type: boolean
53+
default: true
54+
4655

4756
permissions: {}
4857

.github/workflows/datamodel-doc.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
run: |
4949
python3 -m pip install --user -U numpy nltk
5050
python3 -m nltk.downloader -d ~/nltk_data punkt
51+
python3 -m nltk.downloader -d ~/nltk_data punkt_tab
5152
5253
- name: Generate documentation
5354
run: exec bash -exo pipefail O2/scripts/datamodel-doc/update-datamodel.sh
@@ -59,6 +60,7 @@ jobs:
5960
run: |
6061
# git diff --quiet exits with 1 if any tracked files have changed, and
6162
# with 0 otherwise.
63+
set -e
6264
if git diff --quiet; then
6365
exit # Nothing has changed, so no need to send a PR.
6466
fi
@@ -68,9 +70,10 @@ jobs:
6870
git push -f origin auto-datamodel-doc
6971
7072
# Send pull request
71-
# We need to use "hub" ourselves because alisw/pull-request gets
73+
# We need to use "gh" ourselves because alisw/pull-request gets
7274
# confused when multiple repos are checked out.
73-
hub pull-request -b AliceO2Group:master -h alibuild:auto-datamodel-doc \
74-
--no-edit --no-maintainer-edits -m 'Automatic data model update' \
75-
-m "This update to the data model documentation was automatically created from tonight's O2 dev branch." ||
76-
: # If the PR already exists, hub fails, but we've just force-pushed, so we don't need a new PR.
75+
GH_TOKEN="$GITHUB_TOKEN" gh pr create -R AliceO2Group/analysis-framework -B master \
76+
--no-maintainer-edit -t 'Automatic data model update' -b "This update \
77+
to the data model documentation was automatically created from \
78+
tonight's O2 dev branch." || true
79+
# If the PR already exists, hub fails, but we've just force-pushed, so we don't need a new PR.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: Security approval
3+
4+
'on':
5+
pull_request_review:
6+
types:
7+
- edited
8+
- submitted
9+
10+
permissions: {}
11+
12+
jobs:
13+
clean:
14+
name: Security approval
15+
uses: alisw/ali-bot/.github/workflows/pr-security-approval.yml@master
16+
permissions:
17+
pull-requests: read # to get last commit for PR
18+
statuses: write # for set-github-status

.github/workflows/reports.yml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ jobs:
1818

1919
steps:
2020
- uses: actions/checkout@v3
21-
- name: Set up Python 3.7
22-
uses: actions/setup-python@v1
21+
- name: Set up Python 3.10
22+
uses: actions/setup-python@v5
2323
with:
24-
python-version: 3.7
24+
python-version: '3.10'
2525
- uses: actions/cache@v2
2626
name: Configure pip caching
2727
with:
@@ -81,7 +81,7 @@ jobs:
8181
run: |
8282
set -x
8383
mkdir -p doc/data
84-
# We create new files once per month, mostly so that
84+
# We create new files once per month, mostly so that
8585
# we can keep the query results small. It does not
8686
# matter if we get results from different months,
8787
# as what matters is how we merge them.
@@ -96,7 +96,6 @@ jobs:
9696
# being published
9797
LAST_RELEASE="${{ github.event.inputs.LAST_RELEASE_DATE }}"
9898
MERGED_AFTER=${LAST_RELEASE:-$(date -v -14d +%Y-%m-%d)}
99-
10099
# Here we convert all the json files to per subsystem
101100
# logs, using the MERGED_AFTER date to further filter them.
102101
# Notice we can have duplicates in each file,
@@ -106,7 +105,7 @@ jobs:
106105
for f in doc/data/*_prs.json; do
107106
for x in Algorithm Analysis Common DataFormats Detectors EventVisualisation Examples Framework Generators Steer Testing Utilities; do
108107
cat $f | jq ".repository.pullRequests.edges[].node | select(.files.edges[].node.path | test(\"$x\")) | del(.files) | select(.state == \"MERGED\" and .mergedAt >= \"${MERGED_AFTER}\")" > /tmp/${x}_prs.json
109-
if [ ! X`jq -s length /tmp/${x}_prs.json` = X0 ]; then
108+
if [ ! X`jq -s length /tmp/${x}_prs.json` = X0 ]; then
110109
cat /tmp/${x}_prs.json | jq -r '"- [#\(.number)](https://github.com/AliceO2Group/AliceO2/pull/\(.number)) \(.mergedAt | split("T")[0]): \(.title) by [@\(.author.login)](https://github.com/\(.author.login))"' | sort -u >> /tmp/${x}_prs.md
111110
fi
112111
done
@@ -127,11 +126,6 @@ jobs:
127126
git config --global user.name "GitHub Action Bot"
128127
git commit -m "Updated README" -a || echo "No changes to commit"
129128
git push origin HEAD:changelog -f
130-
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
131-
hub pull-request -f -b dev -h changelog \
132-
--no-edit --no-maintainer-edits \
133-
'Auto-generated changelog' \
134-
-m 'The following changelog has been automatically generated.' ||
135-
# If the PR already exists, the force-push will have updated it.
136-
# It's fine if this step fails.
137-
true
129+
# If the PR already exists, the force-push will have updated it.
130+
# It's fine if this step fails.
131+
GH_TOKEN=${{ secrets.GITHUB_TOKEN }} gh pr create -B dev -H changelog -t 'Auto-generated changelog' -b 'The following changelog has been automatically generated.' || true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ compile_commands.json
6363
.vscode
6464
.ycm_extra_conf.py
6565
Session.vim
66+
CMakeLists.txt.user
6667

6768
# Datafiles
6869
gphysi.dat

CCDB/include/CCDB/BasicCCDBManager.h

Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include "CCDB/CcdbApi.h"
1919
#include "CCDB/CCDBTimeStampUtils.h"
2020
#include "CommonUtils/NameConf.h"
21+
#include "Framework/DataTakingContext.h"
22+
#include "Framework/DefaultsHelpers.h"
2123
#include <string>
2224
#include <chrono>
2325
#include <map>
@@ -48,12 +50,19 @@ class CCDBManagerInstance
4850
std::string uuid;
4951
long startvalidity = 0;
5052
long endvalidity = -1;
53+
long cacheValidFrom = 0; // time for which the object was cached
54+
long cacheValidUntil = -1; // object is guaranteed to be valid till this time (modulo new updates)
5155
size_t minSize = -1ULL;
5256
size_t maxSize = 0;
5357
int queries = 0;
5458
int fetches = 0;
5559
int failures = 0;
56-
bool isValid(long ts) { return ts < endvalidity && ts > startvalidity; }
60+
bool isValid(long ts) { return ts < endvalidity && ts >= startvalidity; }
61+
bool isCacheValid(long ts)
62+
{
63+
LOGP(debug, "isCacheValid : {} : {} : {} --> {}", cacheValidFrom, ts, cacheValidUntil, ts < cacheValidUntil && ts >= cacheValidFrom);
64+
return ts < cacheValidUntil && ts >= cacheValidFrom;
65+
}
5766
void clear()
5867
{
5968
noCleanupPtr = nullptr;
@@ -70,6 +79,7 @@ class CCDBManagerInstance
7079
CCDBManagerInstance(std::string const& path) : mCCDBAccessor{}
7180
{
7281
mCCDBAccessor.init(path);
82+
mDeplMode = o2::framework::DefaultsHelpers::deploymentMode();
7383
}
7484
/// set a URL to query from
7585
void setURL(const std::string& url);
@@ -92,6 +102,10 @@ class CCDBManagerInstance
92102
template <typename T>
93103
T* getForTimeStamp(std::string const& path, long timestamp);
94104

105+
/// retrieve an object of type T from CCDB as stored under path and using the timestamp in the middle of the run
106+
template <typename T>
107+
T* getForRun(std::string const& path, int runNumber, bool setRunMetadata = false);
108+
95109
/// retrieve an object of type T from CCDB as stored under path, timestamp and metaData
96110
template <typename T>
97111
T* getSpecific(std::string const& path, long timestamp = -1, MD metaData = MD())
@@ -101,6 +115,13 @@ class CCDBManagerInstance
101115
return getForTimeStamp<T>(path, timestamp);
102116
}
103117

118+
/// retrieve an object of type T from CCDB as stored under path and using the timestamp in the middle of the run + metadata. The run number is provided separately to conform to typical analysis use (in which case metadata does not include runNumber)
119+
template <typename T>
120+
T* getSpecificForRun(std::string const& path, int runNumber, MD metaData = MD());
121+
122+
/// detect online processing modes (i.e. CCDB objects may be updated in the lifetime of the manager)
123+
bool isOnline() const { return mDeplMode == o2::framework::DeploymentMode::OnlineAUX || mDeplMode == o2::framework::DeploymentMode::OnlineDDS || mDeplMode == o2::framework::DeploymentMode::OnlineECS; }
124+
104125
/// retrieve an object of type T from CCDB as stored under path; will use the timestamp member
105126
template <typename T>
106127
T* get(std::string const& path)
@@ -134,7 +155,7 @@ class CCDBManagerInstance
134155
if (!isCachingEnabled()) {
135156
return false;
136157
}
137-
return mCache[path].isValid(timestamp);
158+
return (mCheckObjValidityEnabled && mCache[path].isValid(timestamp)) || mCache[path].isCacheValid(timestamp); // use stricter check
138159
}
139160

140161
/// check if checks of object validity before CCDB query is enabled
@@ -167,15 +188,13 @@ class CCDBManagerInstance
167188
void setFatalWhenNull(bool b) { mFatalWhenNull = b; }
168189

169190
/// A convenience function for MC to fetch
170-
/// valid start and end timestamps given an ALICE run number.
171-
/// On error it fatals (if fatal == true) or else returns the pair -1, -1.
172-
std::pair<int64_t, int64_t> getRunDuration(int runnumber, bool fatal = true) const;
173-
174-
/// A convenience function for MC to fetch
175-
/// valid start and end timestamps given an ALICE run number.
191+
/// valid start and end timestamps for recorded TF data given an ALICE run number.
192+
/// In absence of STF/ETF fields in the RCT with fall back to CTP SOX/EOX then to
193+
/// ECS SOR/EOR.
176194
/// On error it fatals (if fatal == true) or else returns the pair -1, -1.
195+
std::pair<int64_t, int64_t> getRunDuration(int runnumber, bool fatal = true);
177196
static std::pair<int64_t, int64_t> getRunDuration(o2::ccdb::CcdbApi const& api, int runnumber, bool fatal = true);
178-
197+
static std::pair<int64_t, int64_t> getRunDuration(const MD& headers);
179198
std::string getSummaryString() const;
180199

181200
size_t getFetchedSize() const { return mFetchedSize; }
@@ -204,7 +223,7 @@ class CCDBManagerInstance
204223
int mQueries = 0; // total number of object queries
205224
int mFetches = 0; // total number of succesful fetches from CCDB
206225
int mFailures = 0; // total number of failed fetches
207-
226+
o2::framework::DeploymentMode mDeplMode; // O2 deployment mode
208227
ClassDefNV(CCDBManagerInstance, 1);
209228
};
210229

@@ -234,7 +253,7 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp)
234253
} else {
235254
auto& cached = mCache[path];
236255
cached.queries++;
237-
if (mCheckObjValidityEnabled && cached.isValid(timestamp)) {
256+
if ((!isOnline() && cached.isCacheValid(timestamp)) || (mCheckObjValidityEnabled && cached.isValid(timestamp))) {
238257
return reinterpret_cast<T*>(cached.noCleanupPtr ? cached.noCleanupPtr : cached.objPtr.get());
239258
}
240259
ptr = mCCDBAccessor.retrieveFromTFileAny<T>(path, mMetaData, timestamp, &mHeaders, cached.uuid,
@@ -250,6 +269,7 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp)
250269
cached.objPtr.reset(ptr);
251270
}
252271
cached.uuid = mHeaders["ETag"];
272+
253273
try {
254274
if (mHeaders.find("Valid-From") != mHeaders.end()) {
255275
cached.startvalidity = std::stol(mHeaders["Valid-From"]);
@@ -263,6 +283,7 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp)
263283
} else {
264284
cached.endvalidity = std::numeric_limits<long>::max();
265285
}
286+
cached.cacheValidFrom = timestamp;
266287
} catch (std::exception const& e) {
267288
reportFatal("Failed to read validity from CCDB response (Valid-From : " + mHeaders["Valid-From"] + std::string(" Valid-Until: ") + mHeaders["Valid-Until"] + std::string(")"));
268289
}
@@ -276,8 +297,13 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp)
276297
} else if (mHeaders.count("Error")) { // in case of errors the pointer is 0 and headers["Error"] should be set
277298
cached.failures++;
278299
cached.clear(); // in case of any error clear cache for this object
279-
} else { // the old object is valid
280-
ptr = reinterpret_cast<T*>(cached.noCleanupPtr ? cached.noCleanupPtr : cached.objPtr.get());
300+
}
301+
// the old object is valid, fetch cache end of validity
302+
ptr = reinterpret_cast<T*>(cached.noCleanupPtr ? cached.noCleanupPtr : cached.objPtr.get());
303+
if (mHeaders.find("Cache-Valid-Until") != mHeaders.end()) {
304+
cached.cacheValidUntil = std::stol(mHeaders["Cache-Valid-Until"]);
305+
} else {
306+
cached.cacheValidUntil = -1;
281307
}
282308
mHeaders.clear();
283309
mMetaData.clear();
@@ -293,6 +319,27 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp)
293319
return ptr;
294320
}
295321

322+
template <typename T>
323+
T* CCDBManagerInstance::getForRun(std::string const& path, int runNumber, bool setRunMetadata)
324+
{
325+
auto metaData = setRunMetadata ? MD{{"runNumber", std::to_string(runNumber)}} : MD{};
326+
mMetaData = metaData;
327+
return getSpecificForRun<T>(path, runNumber, metaData);
328+
}
329+
330+
template <typename T>
331+
T* CCDBManagerInstance::getSpecificForRun(std::string const& path, int runNumber, MD metaData)
332+
{
333+
auto [start, stop] = getRunDuration(runNumber);
334+
if (start < 0 || stop < 0) {
335+
if (mFatalWhenNull) {
336+
reportFatal(std::string("Failed to get run duration for run ") + std::to_string(runNumber));
337+
}
338+
return nullptr;
339+
}
340+
return getSpecific<T>(path, start / 2 + stop / 2, metaData);
341+
}
342+
296343
class BasicCCDBManager : public CCDBManagerInstance
297344
{
298345
public:

CCDB/include/CCDB/CCDBDownloader.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ typedef struct DownloaderRequestData {
5252
HeaderObjectPair_t hoPair;
5353
std::map<std::string, std::string>* headers;
5454
std::string userAgent;
55+
curl_slist* optionsList;
5556

5657
std::function<bool(std::string)> localContentCallback;
5758
} DownloaderRequestData;
@@ -86,6 +87,11 @@ curl_socket_t opensocketCallback(void* clientp, curlsocktype purpose, struct cur
8687
*/
8788
void onUVClose(uv_handle_t* handle);
8889

90+
enum DownloaderErrorLevel {
91+
MINOR,
92+
SEVERE
93+
};
94+
8995
/// A class encapsulating and performing simple CURL requests in terms of a so-called CURL multi-handle.
9096
/// A multi-handle allows to use a connection pool (connection cache) in the CURL layer even
9197
/// with short-lived CURL easy-handles. Thereby the overhead of connection to servers can be
@@ -296,6 +302,7 @@ class CCDBDownloader
296302
int hostInd;
297303
int locInd;
298304
DownloaderRequestData* requestData;
305+
curl_slist** options;
299306
} PerformData;
300307
#endif
301308

@@ -421,6 +428,6 @@ typedef struct DataForClosingSocket {
421428
curl_socket_t socket;
422429
} DataForClosingSocket;
423430

424-
} // namespace o2
431+
} // namespace o2::ccdb
425432

426433
#endif // O2_CCDB_CCDBDOWNLOADER_H

0 commit comments

Comments
 (0)