Skip to content

Commit

Permalink
Merge pull request #138 from inab/137-error-when-adding-dot-file-to-o…
Browse files Browse the repository at this point in the history
…utput-ro-crate

Fixed several path handling issues in several parts of RO-Crate gener…
  • Loading branch information
jmfernandez authored Dec 8, 2024
2 parents 6ce9872 + 51cd40f commit e3c066e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
8 changes: 6 additions & 2 deletions wfexs_backend/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,9 @@ def processStagedWorkdirCommand(
)
expanded_licences = wB.curate_licence_list(op_licences)
wfInstance.createStageResearchObject(
filename=args.staged_workdir_command_args[1],
filename=pathlib.Path(
args.staged_workdir_command_args[1]
),
payloads=doMaterializedROCrate,
licences=expanded_licences,
resolved_orcids=resolved_orcids,
Expand All @@ -1078,7 +1080,9 @@ def processStagedWorkdirCommand(
)
expanded_licences = wB.curate_licence_list(op_licences)
wfInstance.createResultsResearchObject(
filename=args.staged_workdir_command_args[1],
filename=pathlib.Path(
args.staged_workdir_command_args[1]
),
payloads=doMaterializedROCrate,
licences=expanded_licences,
resolved_orcids=resolved_orcids,
Expand Down
26 changes: 19 additions & 7 deletions wfexs_backend/ro_crate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2631,19 +2631,26 @@ def addWorkflowExecution(
crate_meta_outputs: "MutableSequence[rocrate.model.entity.Entity]" = []
if stagedExec.diagram is not None:
# This is the original diagram, in DOT format (for now)
abs_diagram = os.path.join(self.work_dir, stagedExec.diagram)
abs_diagram = (
stagedExec.diagram
if stagedExec.diagram.is_absolute()
else (self.work_dir / stagedExec.diagram).resolve()
)
rel_diagram = stagedExec.diagram.relative_to(self.work_dir)
dot_file = WorkflowDiagram(
self.crate,
source=os.path.join(self.work_dir, stagedExec.diagram),
dest_path=stagedExec.diagram,
source=abs_diagram,
dest_path=rel_diagram,
fetch_remote=False,
validate_url=False,
properties={
"contentSize": str(os.stat(abs_diagram).st_size),
"contentSize": str(abs_diagram.stat().st_size),
"sha256": ComputeDigestFromFile(
abs_diagram, "sha256", repMethod=hexDigest
),
"encodingFormat": magic.from_file(abs_diagram, mime=True),
"encodingFormat": magic.from_file(
abs_diagram.as_posix(), mime=True
),
},
)
self.crate.add(dot_file)
Expand All @@ -2663,7 +2670,12 @@ def addWorkflowExecution(
os.close(png_dot_handle)

with tempfile.NamedTemporaryFile() as d_err:
dot_cmd = [self.dot_binary, "-Tpng", "-o" + png_dot_path, abs_diagram]
dot_cmd = [
self.dot_binary,
"-Tpng",
"-o" + png_dot_path,
abs_diagram.as_posix(),
]

diagram_dot_path_for_rocrate = stagedExec.diagram.relative_to(
self.work_dir
Expand All @@ -2687,7 +2699,7 @@ def addWorkflowExecution(
png_dot_file = WorkflowDiagram(
self.crate,
source=png_dot_path,
dest_path=stagedExec.diagram.as_posix() + ".png",
dest_path=rel_diagram.as_posix() + ".png",
fetch_remote=False,
validate_url=False,
properties={
Expand Down

0 comments on commit e3c066e

Please sign in to comment.