Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

ECDC-3518-only-partial-depends-on-support #1036

Merged
merged 33 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
cf7ed8c
Commit of change for public test of further cases
ggoneiESS Aug 4, 2023
c124cf0
fixed logic, added test, removed incorrect and unused json
ggoneiESS Aug 11, 2023
b7cd434
fixed other tests broken due to changes
ggoneiESS Aug 11, 2023
64c9f63
fixing warnings on types, syntax
ggoneiESS Aug 11, 2023
503ae27
Update NeXus HTML documentation
cow-bot Aug 11, 2023
89cd557
typo in addition of name and parent_node to module.py
ggoneiESS Aug 11, 2023
709ee7d
use relative path for depends_on test
ggoneiESS Aug 30, 2023
73c0ac9
Removed non-ticket changes from this branch
ggoneiESS Sep 12, 2023
8b41c19
GO FORMAT YOURSELF (black)
cow-bot Sep 12, 2023
fa5dd8e
Update NeXus HTML documentation
cow-bot Sep 12, 2023
81ddeb8
removed a cast for strict typing
ggoneiESS Sep 12, 2023
bd61bc9
updated code wrt review comments
ggoneiESS Sep 12, 2023
d904075
GO FORMAT YOURSELF (black)
cow-bot Sep 13, 2023
99c8646
Update NeXus HTML documentation
cow-bot Sep 13, 2023
976ab11
Adjusted so depends_on of len 1 are read correctly
ggoneiESS Sep 13, 2023
771d188
flake8 fix
ggoneiESS Sep 13, 2023
987164b
test verification and fix
ggoneiESS Sep 14, 2023
fa7bdce
GO FORMAT YOURSELF (black)
cow-bot Sep 14, 2023
0d9932b
Update NeXus HTML documentation
cow-bot Sep 14, 2023
3c6d1cb
let's warn the user too about dodgy relative paths
ggoneiESS Sep 14, 2023
ce090f3
Merge remote-tracking branch 'refs/remotes/origin/ECDC-3518-only-part…
ggoneiESS Sep 15, 2023
f5e0801
better aligned _create_transformations with load_from_json.py
ggoneiESS Sep 15, 2023
943fbaf
GO FORMAT YOURSELF (black)
cow-bot Sep 15, 2023
45a7189
Update NeXus HTML documentation
cow-bot Sep 15, 2023
1e59d06
Merge branch 'main' into ECDC-3518-only-partial-depends-on-support
ggoneiESS Sep 15, 2023
5e89859
parameterised test with all inputs for single depends_on
ggoneiESS Sep 15, 2023
7c1d072
Merge remote-tracking branch 'refs/remotes/origin/ECDC-3518-only-part…
ggoneiESS Sep 15, 2023
9a47fb8
flake fix
ggoneiESS Sep 15, 2023
8d2e148
added further tests specified in review
ggoneiESS Sep 18, 2023
1165471
GO FORMAT YOURSELF (black)
cow-bot Sep 18, 2023
3bfcf0a
Update NeXus HTML documentation
cow-bot Sep 18, 2023
91dee44
amended tests
ggoneiESS Sep 18, 2023
cfa3747
Merge remote-tracking branch 'refs/remotes/origin/ECDC-3518-only-part…
ggoneiESS Sep 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions nexus_constructor/json/json_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class TransformDependencyMissing:
message: str = attr.ib()


@attr.s
class RelativeDependsonWrong:
message = attr.ib(type=str)


@attr.s
class NameFieldMissing:
message: str = attr.ib()
Expand All @@ -44,6 +49,7 @@ class NXClassAttributeMissing:
InvalidShape,
InvalidTransformation,
TransformDependencyMissing,
RelativeDependsonWrong,
NameFieldMissing,
NXClassAttributeMissing,
]
Expand Down
51 changes: 41 additions & 10 deletions nexus_constructor/json/load_from_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
NameFieldMissing,
NXClassAttributeMissing,
TransformDependencyMissing,
RelativeDependsonWrong,
)
from nexus_constructor.json.load_from_json_utils import (
DEPENDS_ON_IGNORE,
Expand Down Expand Up @@ -113,8 +114,19 @@ def _set_components_depends_on(self):
except KeyError:
self.warnings.append(
TransformDependencyMissing(
f"Component {component_name} depends on {depends_on_id.transform_name} in component "
f"{depends_on_id.component_name}, but that transform was not successfully loaded from the JSON"
f"Component {component_name} depends on "
+ (
depends_on_id.transform_name
if depends_on_id is not None
else "Unknown"
ggoneiESS marked this conversation as resolved.
Show resolved Hide resolved
)
+ " in component "
+ (
depends_on_id.component_name
if depends_on_id is not None
else "Unknown"
)
+ ", but that transform was not successfully loaded from the JSON"
)
)

Expand All @@ -138,9 +150,19 @@ def _set_transforms_depends_on(self):
except KeyError:
self.warnings.append(
TransformDependencyMissing(
f"Transformation {transform_id.transform_name} in component {transform_id.component_name} "
f"depends on {depends_on_id.transform_name} in component {depends_on_id.component_name}, "
f"but that transform was not successfully loaded from the JSON"
f"Transformation {transform_id.transform_name} in component {transform_id.component_name} depends on "
+ (
depends_on_id.transform_name
if depends_on_id is not None
else "Unknown"
ggoneiESS marked this conversation as resolved.
Show resolved Hide resolved
)
+ " in component "
+ (
depends_on_id.component_name
if depends_on_id is not None
else "Unknown"
)
+ ", but that transform was not successfully loaded from the JSON"
)
)

Expand Down Expand Up @@ -387,11 +409,20 @@ def _add_transform_and_shape_to_component(self, component, children_dict):
)
transformation_reader.add_transformations_to_component()
self.warnings += transformation_reader.warnings
depends_on_path = _find_depends_on_path(children_dict, component.name)
if depends_on_path not in DEPENDS_ON_IGNORE:
depends_on_id = TransformId(
*get_component_and_transform_name(depends_on_path)
)
depends_on = _find_depends_on_path(children_dict, component.name)
if depends_on not in DEPENDS_ON_IGNORE:
if depends_on[0] != "/":
# we are always in the NXtransformations group but the path could be anything
if len(depends_on.split("/")) <= 2:
depends_on = "/transformations/" + depends_on.split("/")[-1]
else:
self.warnings.append(
RelativeDependsonWrong(
f"depends_on in component {component.name} is relative, but we only support relative paths of length 1 or 2"
)
)
depends_on = component.absolute_path + depends_on
depends_on_id = TransformId(*get_component_and_transform_name(depends_on))
self._components_depends_on[component.name] = (component, depends_on_id)
else:
self._components_depends_on[component.name] = (component, None)
Expand Down
2 changes: 1 addition & 1 deletion nexus_constructor/json/load_from_json_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
NodeType,
)

DEPENDS_ON_IGNORE = [None, "."]
DEPENDS_ON_IGNORE = [None, 'None', ".", ""]


def _find_shape_information(children: List[Dict]) -> Union[Dict, None]:
Expand Down
12 changes: 10 additions & 2 deletions nexus_constructor/json/transformation_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,15 @@ def _create_transformations(self, json_transformations: list):
depends_on = _find_attribute_from_list_or_dict(
CommonAttrs.DEPENDS_ON, attributes
)
if depends_on not in DEPENDS_ON_IGNORE:
# relative paths warnings were sent to user when JSON was read in
if depends_on[0] != "/":
depends_on = (
self.parent_component.absolute_path
+ "/transformations/"
danesss marked this conversation as resolved.
Show resolved Hide resolved
+ depends_on
)

if module == DATASET:
values = self._get_transformation_attribute(
CommonKeys.VALUES, config, name
Expand All @@ -319,15 +328,14 @@ def _create_transformations(self, json_transformations: list):
angle_or_magnitude = 0.0
else:
continue
temp_depends_on = None

transform = self.parent_component._create_and_add_transform(
name=name,
transformation_type=transformation_type,
angle_or_magnitude=angle_or_magnitude,
units=units,
vector=QVector3D(*vector),
depends_on=temp_depends_on,
depends_on=None,
values=values,
)
offset = self._find_attribute_in_list(CommonAttrs.OFFSET, name, attributes)
Expand Down
2 changes: 1 addition & 1 deletion nx-class-documentation/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ <h1>User Manual and Reference Documentation<a class="headerlink" href="#user-man
</div>
<hr class="docutils" />
<p class="rubric">Publishing Information</p>
<p>This manual built Sep 15, 2023.</p>
<p>This manual built Sep 18, 2023.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p>This document is available in these formats online:</p>
Expand Down
2 changes: 1 addition & 1 deletion nx-class-documentation/html/searchindex.js

Large diffs are not rendered by default.

Loading