From 0b2bc42898792eeb8c135b6550de3089c5334749 Mon Sep 17 00:00:00 2001 From: Pierre Gibertini Date: Thu, 22 Feb 2024 15:32:02 +0100 Subject: [PATCH 01/11] Fix: binary mode doesn't take an encoding argument --- dessia_common/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dessia_common/core.py b/dessia_common/core.py index 6e4d1a0fa..78956e3e1 100644 --- a/dessia_common/core.py +++ b/dessia_common/core.py @@ -708,7 +708,7 @@ def to_stl(self, filepath: str): if not filepath.endswith('.stl'): filepath += '.stl' - with open(filepath, 'wb', encoding='utf-8') as file: + with open(filepath, 'wb') as file: self.to_stl_stream(stream=file) def babylonjs(self, use_cdn=True, debug=False, **kwargs): From be846ce9b762fdee8d9dffc287cc34228adbc77e Mon Sep 17 00:00:00 2001 From: Pierre Gibertini Date: Thu, 22 Feb 2024 15:33:42 +0100 Subject: [PATCH 02/11] Update: CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5c9cd41c..2cfcd1de8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.16.2 + +### Fix + +- PhysicalObject : to_stl + ## 0.16.1 ### Fix From ade756c9ccfc7517c962483bc16ff98ff9261f31 Mon Sep 17 00:00:00 2001 From: younesdessia Date: Wed, 28 Feb 2024 22:12:32 +0100 Subject: [PATCH 03/11] Fix: object_default/schema --- dessia_common/schemas/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dessia_common/schemas/core.py b/dessia_common/schemas/core.py index 2e2cd7fe7..b77657743 100644 --- a/dessia_common/schemas/core.py +++ b/dessia_common/schemas/core.py @@ -1674,7 +1674,7 @@ def object_default(default_value: CoreDessiaObject = UNDEFINED, class_schema: Cl Return serialized user default if definition, else None. """ - if default_value is not UNDEFINED: + if default_value is not UNDEFINED and default_value is not None: return default_value.to_dict(use_pointers=False) if class_schema is not None: # TODO Should we implement this ? Right now, tests state that the result is None From dde84b82329c2840e3ef1df0483554b60bf1c28a Mon Sep 17 00:00:00 2001 From: younesdessia Date: Thu, 7 Mar 2024 13:30:49 +0100 Subject: [PATCH 04/11] Fix: add block index to workflowrun zip --- dessia_common/core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dessia_common/core.py b/dessia_common/core.py index 6e4d1a0fa..046f657bf 100644 --- a/dessia_common/core.py +++ b/dessia_common/core.py @@ -584,7 +584,8 @@ def zip_settings(self): method_name = export_format.method_name stream_class = dcf.StringFile if export_format.text else dcf.BinaryFile stream = stream_class(filename=f"export.{export_format.extension}") - getattr(self, method_name)(stream) + block_index = export_format.args.get('block_index', None) + getattr(self, method_name)(stream, block_index) if block_index else getattr(self, method_name)(stream) streams.append(stream) return streams From 948b196fc55cf598449cac3ad68a7c9d129835ef Mon Sep 17 00:00:00 2001 From: younesdessia Date: Thu, 7 Mar 2024 18:25:27 +0100 Subject: [PATCH 05/11] Fix: CI --- dessia_common/core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dessia_common/core.py b/dessia_common/core.py index 046f657bf..8d61dd698 100644 --- a/dessia_common/core.py +++ b/dessia_common/core.py @@ -585,7 +585,8 @@ def zip_settings(self): stream_class = dcf.StringFile if export_format.text else dcf.BinaryFile stream = stream_class(filename=f"export.{export_format.extension}") block_index = export_format.args.get('block_index', None) - getattr(self, method_name)(stream, block_index) if block_index else getattr(self, method_name)(stream) + _ = getattr(self, method_name)(stream, block_index) if block_index\ + else getattr(self, method_name)(stream) streams.append(stream) return streams From 025e354d00a2065dbeffd7a9090383045bbfcf43 Mon Sep 17 00:00:00 2001 From: younesdessia Date: Thu, 7 Mar 2024 18:31:16 +0100 Subject: [PATCH 06/11] write changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5c9cd41c..e8fcfb935 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.16.2 + +### Fix + +- Export: Add block_index if export blocks + + ## 0.16.1 ### Fix From 8a6cb76aadc95acec9495fd2c39433ccdf70173f Mon Sep 17 00:00:00 2001 From: younesdessia Date: Fri, 8 Mar 2024 14:26:36 +0100 Subject: [PATCH 07/11] write changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5c9cd41c..1c04fce7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.16.2 + +### Fix + +- Schema : Take `None` default value into account + + ## 0.16.1 ### Fix From 1453cb446e6ad764602a4833732fa953801a26d8 Mon Sep 17 00:00:00 2001 From: younesdessia Date: Mon, 25 Mar 2024 16:05:42 +0100 Subject: [PATCH 08/11] perf: override workflowrun zip_settings --- dessia_common/core.py | 11 ++--------- dessia_common/workflow/core.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/dessia_common/core.py b/dessia_common/core.py index 8d61dd698..28704c0ce 100644 --- a/dessia_common/core.py +++ b/dessia_common/core.py @@ -572,21 +572,14 @@ 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": method_name = export_format.method_name stream_class = dcf.StringFile if export_format.text else dcf.BinaryFile stream = stream_class(filename=f"export.{export_format.extension}") - block_index = export_format.args.get('block_index', None) - _ = getattr(self, method_name)(stream, block_index) if block_index\ - else getattr(self, method_name)(stream) + getattr(self, method_name)(stream) streams.append(stream) return streams diff --git a/dessia_common/workflow/core.py b/dessia_common/workflow/core.py index 881e0695f..d05bddd34 100644 --- a/dessia_common/workflow/core.py +++ b/dessia_common/workflow/core.py @@ -1965,6 +1965,20 @@ 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._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=f"export.{export_format.extension}") + block_index = export_format.args.get('block_index', None) + _ = getattr(self, method_name)(stream, block_index) if block_index\ + else getattr(self, method_name)(stream) + 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. """ From c92fe7b1853264d686ac05c5278a81cce9cf4487 Mon Sep 17 00:00:00 2001 From: GhislainJ Date: Tue, 26 Mar 2024 13:59:54 +0100 Subject: [PATCH 09/11] build(numpy): force version lower to 2.0.0 --- CHANGELOG.md | 4 ++++ setup.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 500ae6482..322c8724b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - WorkflowRun : Compute memory usage, subtract before_memory +### Build + +- Numpy : Restrict version to lower 2.0.0 + ## 0.16.1 diff --git a/setup.py b/setup.py index 3907779a9..0bf4c979b 100644 --- a/setup.py +++ b/setup.py @@ -145,7 +145,7 @@ def get_branch(): "humanize", "matplotlib", "networkx", - "numpy", + "numpy<2.0.0", "openpyxl", "orjson>=3.8.0", "pandas", From b72d26e5ef02aa9ceb97972aba256332cc9e0e6a Mon Sep 17 00:00:00 2001 From: younesdessia Date: Tue, 26 Mar 2024 14:08:39 +0100 Subject: [PATCH 10/11] Perf: schema unit test --- .../test_computation_structures.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/test_schemas/test_computation_structures.py b/tests/test_schemas/test_computation_structures.py index 2c4a5d0f9..82f1bf6f7 100644 --- a/tests/test_schemas/test_computation_structures.py +++ b/tests/test_schemas/test_computation_structures.py @@ -1,4 +1,6 @@ -from dessia_common.schemas.core import ClassProperty, MethodTypeProperty, AttributeTypeProperty, SchemaAttribute +from dessia_common.core import DessiaObject +from dessia_common.schemas.core import ClassProperty, MethodTypeProperty, AttributeTypeProperty, SchemaAttribute, \ + CustomClass from dessia_common.forms import StandaloneObject from dessia_common.typings import MethodType, ClassMethodType, AttributeType, ClassAttributeType from typing import Type @@ -8,6 +10,7 @@ CUSTOM_CLASS = SchemaAttribute(name="custom_class") +CUSTOM_CLASS_DEFAULT = SchemaAttribute(name="custom_class", editable=True, title="CustomClass", default_value=None) ATTRIBUTE = SchemaAttribute(name="attribute") METHOD = SchemaAttribute(name="method") @@ -58,6 +61,19 @@ def test_attributes(self, schema, expected_type, expected_typing, expected_class self.assertEqual(computed_schema["properties"]["class_"]["type"], "object") self.assertEqual(computed_schema["properties"]["class_"]["python_typing"], expected_class) + @parameterized.expand([ + (CustomClass(annotation=DessiaObject, attribute=CUSTOM_CLASS_DEFAULT), + "object", "dessia_common.core.DessiaObject"), + (CustomClass(annotation=DessiaObject, attribute=CUSTOM_CLASS), + "object", "dessia_common.core.DessiaObject") + ]) + def test_custom_classes(self, schema, expected_type, expected_python_typing): + computed_schema = schema.to_dict() + self.assertEqual(computed_schema["type"], expected_type) + self.assertEqual(computed_schema["python_typing"], expected_python_typing) + self.assertEqual(computed_schema["title"], schema.attribute.title) + self.assertEqual(computed_schema["editable"], schema.attribute.editable) + if __name__ == '__main__': unittest.main(verbosity=2) From 627816d62d17cf13f79d41c5c4ab9a0f4d16d0d2 Mon Sep 17 00:00:00 2001 From: younesdessia Date: Tue, 26 Mar 2024 14:20:47 +0100 Subject: [PATCH 11/11] Update: WorkflowRun zip export --- dessia_common/workflow/core.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dessia_common/workflow/core.py b/dessia_common/workflow/core.py index d05bddd34..9241463b2 100644 --- a/dessia_common/workflow/core.py +++ b/dessia_common/workflow/core.py @@ -1968,14 +1968,13 @@ def to_markdown(self, **kwargs) -> str: def zip_settings(self): """ Returns a list of streams that contain different exports of the objects. """ streams = [] - for export_format in self._export_formats(): + 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=f"export.{export_format.extension}") - block_index = export_format.args.get('block_index', None) - _ = getattr(self, method_name)(stream, block_index) if block_index\ - else getattr(self, method_name)(stream) + 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