Skip to content

Commit

Permalink
fixed corrupt provenance object + serialization; added CODEOWNERS
Browse files Browse the repository at this point in the history
  • Loading branch information
jblom committed Oct 30, 2023
1 parent a9f4068 commit f05dfcb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @jblom @Veldhoen
10 changes: 5 additions & 5 deletions models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass
from dataclasses import dataclass, field
from enum import Enum
from typing import Optional, TypedDict
from typing import Optional, TypedDict, Dict


# These are the types of output this worker (possibly) provides (depending on configuration)
Expand Down Expand Up @@ -35,8 +35,8 @@ class Provenance:
input_data: dict[str, str]
output_data: dict[str, str]
parameters: Optional[dict] = None
software_version: Optional[dict[str, str]] = None
steps: Optional[list["Provenance"]] = None # a list of subactivity provenance items
software_version: Optional[Dict[str, str]] = None
steps: Optional[list["Provenance"]] = field(default_factory=list["Provenance"])

def to_json(self):
return {
Expand All @@ -48,7 +48,7 @@ def to_json(self):
"software_version": self.software_version, # .to_json
"input_data": self.input_data, # .to_json
"output_data": self.output_data, # .to_json
"steps": [step.to_json for step in self.steps],
"steps": [step.to_json() for step in self.steps],
}


Expand Down
8 changes: 6 additions & 2 deletions provenance.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from functools import reduce
import json
import logging
import os
from time import time
Expand Down Expand Up @@ -39,8 +40,11 @@ def generate_full_provenance_chain(
)

output_file = get_provenance_file(input_file_path)
with open(output_file, "w+") as f:
f.write(str(provenance.to_json()))
fdata = provenance.to_json()
logger.info("Going to write the following to disk:")
logger.info(fdata)
with open(output_file, "w", encoding="utf-8") as f:
json.dump(fdata, f, ensure_ascii=False, indent=4)
logger.info(f"Wrote provenance info to file: {output_file}")
return provenance

Expand Down
1 change: 0 additions & 1 deletion worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ def callback(self, task: Task, doc: Document) -> CallbackResponse:
"message": "Successfully generated VisXP data for the next worker",
}

# TODO adapt to VisXP
def save_to_dane_index(
self,
doc: Document,
Expand Down

0 comments on commit f05dfcb

Please sign in to comment.