Skip to content

Commit

Permalink
Merge pull request #679 from Dessia-tech/fix/zip_settings
Browse files Browse the repository at this point in the history
Fix: add block index to workflowrun zip
  • Loading branch information
GhislainJ committed Mar 26, 2024
2 parents f005633 + 6e41d77 commit fe0642f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fix

- Export: Add block_index if export blocks
- PhysicalObject : Remove to_stl encoding element
- Schema : Take `None` default value into account
- WorkflowRun : Compute memory usage, subtract before_memory
Expand Down
7 changes: 1 addition & 6 deletions dessia_common/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,12 +572,7 @@ def to_docx(self, filepath: str):
self.to_docx_stream(filepath)

def zip_settings(self):
"""
Returns a list of streams containing different representations of the object.
Excel file stream generated by calling 'to_xlsx_stream' method.
JSON file stream generated by calling 'save_to_stream' method.
"""
""" Returns a list of streams that contain different exports of the objects. """
streams = []
for export_format in self._export_formats():
if export_format.extension != "zip":
Expand Down
13 changes: 13 additions & 0 deletions dessia_common/workflow/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1965,6 +1965,19 @@ def to_markdown(self, **kwargs) -> str:
return template.substitute(name=self.name, workflow_name=self.workflow.name,
output_table=output_table, execution_info=execution_info)

def zip_settings(self):
""" Returns a list of streams that contain different exports of the objects. """
streams = []
for export_format in self.workflow.blocks_export_formats:
if export_format.extension != "zip":
method_name = export_format.method_name
stream_class = StringFile if export_format.text else BinaryFile
stream = stream_class(filename=export_format.export_name)
block_index = export_format.args.get('block_index')
getattr(self, method_name)(stream, block_index)
streams.append(stream)
return streams


def initialize_workflow(dict_, global_dict, pointers_memo) -> Workflow:
""" Generate blocks, pipes, detached_variables and output from a serialized state. """
Expand Down

0 comments on commit fe0642f

Please sign in to comment.