Skip to content

Commit

Permalink
Update prov (#264)
Browse files Browse the repository at this point in the history
* used clisops version instead of daops

* added provider to prov

* update prov test
  • Loading branch information
cehbrecht authored Nov 14, 2024
1 parent 90396e9 commit 3fa3e55
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
28 changes: 20 additions & 8 deletions src/rook/provenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
import prov.model as prov
from prov.dot import prov_to_dot

from pywps import configuration

# prov namespace
PROV_ORGANISATION = prov.PROV["Organization"]
PROV_PROVIDER = prov.PROV["Agent"]
PROV_SOFTWARE_AGENT = prov.PROV["SoftwareAgent"]

# provone namespace
Expand Down Expand Up @@ -43,7 +46,7 @@ def identifier(self):
return self._identifier

def start(self, workflow=False):
from daops import __version__ as daops_version
from clisops import __version__ as clisops_version
from rook import __version__ as rook_version

self.doc = prov.ProvDocument()
Expand All @@ -62,6 +65,14 @@ def start(self, workflow=False):
DCTERMS_SOURCE: "https://cds.climate.copernicus.eu",
},
)
provider = self.doc.agent(
ROOCS["Provider"],
{
prov.PROV_TYPE: PROV_PROVIDER,
prov.PROV_LABEL: "Provider",
DCTERMS_SOURCE: configuration.get_config_value("metadata:main", "provider", "Rook"),
},
)
self.sw_rook = self.doc.agent(
ROOCS[f"rook_v{rook_version}"],
{
Expand All @@ -71,12 +82,13 @@ def start(self, workflow=False):
},
)
self.doc.wasAttributedTo(self.sw_rook, project_cds)
self.sw_daops = self.doc.agent(
ROOCS[f"daops_v{daops_version}"],
self.doc.wasAttributedTo(self.sw_rook, provider)
self.sw_clisops = self.doc.agent(
ROOCS[f"clisops_v{clisops_version}"],
{
prov.PROV_TYPE: PROV_SOFTWARE_AGENT,
prov.PROV_LABEL: "DAOPS",
DCTERMS_SOURCE: f"https://github.com/roocs/daops/releases/tag/v{daops_version}",
prov.PROV_LABEL: "clisops",
DCTERMS_SOURCE: f"https://github.com/roocs/clisops/releases/tag/v{clisops_version}",
},
)
# workflow
Expand Down Expand Up @@ -134,11 +146,11 @@ def add_operator(self, operator, parameters, collection, output):
# input data
ds_in = os.path.basename(collection[0])
op_input = self._data_entitiy(identifier=ROOCS[ds_in], label=ds_in)
# operator started by daops
# operator started by clisops
if self._workflow:
self.doc.wasAssociatedWith(op, agent=self.sw_daops, plan=self._workflow)
self.doc.wasAssociatedWith(op, agent=self.sw_clisops, plan=self._workflow)
else:
self.doc.start(op, starter=self.sw_daops, trigger=self.sw_rook)
self.doc.start(op, starter=self.sw_clisops, trigger=self.sw_rook)
# Generated output file
for out in output:
ds_out = os.path.basename(out)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_provenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ def test_prov_simple(tmpdir):
assert (
doc["agent"]["roocs:C3S_CDS"]["prov:label"] == "Copernicus Climate Data Store"
)
assert (
doc["agent"]["roocs:Provider"]["prov:label"] == "Provider"
)


def test_prov_workflow(tmpdir):
Expand All @@ -32,3 +35,6 @@ def test_prov_workflow(tmpdir):
assert (
doc["agent"]["roocs:C3S_CDS"]["prov:label"] == "Copernicus Climate Data Store"
)
assert (
doc["agent"]["roocs:Provider"]["prov:label"] == "Provider"
)

0 comments on commit 3fa3e55

Please sign in to comment.