generated from NASA-PDS/template-repo-python
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reimplement provenance sweeper with non-redundant processing
record skipping is based on provenance software version this updated version writes null values for latest products, rather than not writing the metadata attribute
- Loading branch information
1 parent
82962a6
commit 3f94d33
Showing
4 changed files
with
132 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
METADATA_SUCCESSOR_KEY = "ops:Provenance/ops:superseded_by" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Dict | ||
from typing import Optional | ||
|
||
from pds.registrysweepers.provenance.constants import METADATA_SUCCESSOR_KEY | ||
from pds.registrysweepers.provenance.versioning import SWEEPERS_PROVENANCE_VERSION | ||
from pds.registrysweepers.provenance.versioning import SWEEPERS_PROVENANCE_VERSION_METADATA_KEY | ||
from pds.registrysweepers.utils.productidentifiers.pdslidvid import PdsLidVid | ||
|
||
|
||
class ProvenanceRecord: | ||
lidvid: PdsLidVid | ||
_successor: Optional[PdsLidVid] | ||
skip_write: bool | ||
|
||
def __init__(self, lidvid: PdsLidVid, successor: Optional[PdsLidVid], skip_write: bool = False): | ||
self.lidvid = lidvid | ||
self._successor = successor | ||
self.skip_write = skip_write | ||
|
||
@property | ||
def successor(self) -> Optional[PdsLidVid]: | ||
return self._successor | ||
|
||
def set_successor(self, successor: PdsLidVid): | ||
if successor != self._successor: | ||
self._successor = successor | ||
self.skip_write = False | ||
|
||
@staticmethod | ||
def from_source(_source: Dict) -> ProvenanceRecord: | ||
if METADATA_SUCCESSOR_KEY in _source: | ||
successor = PdsLidVid.from_string(_source[METADATA_SUCCESSOR_KEY]) | ||
else: | ||
successor = None | ||
skip_write = _source.get(SWEEPERS_PROVENANCE_VERSION_METADATA_KEY, 0) >= SWEEPERS_PROVENANCE_VERSION | ||
return ProvenanceRecord( | ||
lidvid=PdsLidVid.from_string(_source["lidvid"]), successor=successor, skip_write=skip_write | ||
) | ||
|
||
@staticmethod | ||
def from_doc(doc: Dict) -> ProvenanceRecord: | ||
return ProvenanceRecord.from_source(doc["_source"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Defines constants used for versioning updated documents with the in-use version of sweepers | ||
# SWEEPERS_VERSION must be incremented any time sweepers is changed in a way which requires reprocessing of | ||
# previously-processed data | ||
from pds.registrysweepers.utils.misc import get_sweeper_version_metadata_key | ||
|
||
SWEEPERS_PROVENANCE_VERSION = 1 | ||
SWEEPERS_PROVENANCE_VERSION_METADATA_KEY = get_sweeper_version_metadata_key("provenance") |