Skip to content

Commit

Permalink
use a dedicated method to update the metadata. At the moment te QCCDB…
Browse files Browse the repository at this point in the history
… requires to specify the start of validity behind the scene.
  • Loading branch information
Barthelemy committed Nov 1, 2023
1 parent db27d46 commit e4b576b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
17 changes: 17 additions & 0 deletions Framework/script/RepoCleaner/qcrepocleaner/Ccdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,24 @@ def updateValidity(self, version: ObjectVersion, valid_from: int, valid_to: int,
except requests.exceptions.RequestException as e:
logging.error(f"Exception in updateValidity: {traceback.format_exc()}")

@dryable.Dryable()
def updateMetadata(self, version: ObjectVersion, metadata):
logger.debug(f"update metadata : {metadata}")
full_path = self.url + '/' + version.path + '/' + str(version.validFrom) + '/' + str(version.uuid) + '?'
if metadata is not None:
for key in metadata:
full_path += key + "=" + metadata[key] + "&"
if self.set_adjustable_eov:
logger.debug(f"As the parameter force is set, we add metadata adjustableEOV")
full_path += "adjustableEOV=1&"
try:
headers = {'Connection': 'close'}
r = requests.put(full_path, headers=headers)
r.raise_for_status()
except requests.exceptions.RequestException as e:
logging.error(f"Exception in updateMetadata: {traceback.format_exc()}")

@dryable.Dryable()
def putVersion(self, version: ObjectVersion, data):
'''
:param version: An ObjectVersion that describes the data to be uploaded.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

logger = logging # default logger


def process(ccdb: Ccdb, object_path: str, delay: int, from_timestamp: int, to_timestamp: int,
extra_params: Dict[str, str]):
'''
Expand Down Expand Up @@ -110,8 +111,7 @@ def process(ccdb: Ccdb, object_path: str, delay: int, from_timestamp: int, to_t
preservation_list.extend(run_versions)
continue
# flag second with `cleaner_2nd`
ccdb.updateValidity(run_versions[1], run_versions[1].validFrom, run_versions[1].validTo,
{'cleaner_2nd': 'true'})
ccdb.updateMetadata(run_versions[1], {'cleaner_2nd': 'true'})
# delete first and last versions in the bucket
logger.debug(f" delete the first and last versions")
deletion_list.append(run_versions[-1])
Expand All @@ -132,7 +132,7 @@ def process(ccdb: Ccdb, object_path: str, delay: int, from_timestamp: int, to_t
logger.debug(f" --> preserve")
last_preserved = v
if migrate_to_EOS:
ccdb.updateValidity(v, v.validFrom, v.validTo, metadata_for_preservation)
ccdb.updateMetadata(v, metadata_for_preservation)
preservation_list.append(last_preserved)
else: # in between period --> delete
logger.debug(f" --> delete")
Expand Down

0 comments on commit e4b576b

Please sign in to comment.