Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add depends_on path to error output #248

Merged
merged 6 commits into from
Nov 12, 2024
Merged

Add depends_on path to error output #248

merged 6 commits into from
Nov 12, 2024

Conversation

ggoneiESS
Copy link
Contributor

It's hard to diagnose current web output as there is no simple way to see what is being warned about

Copy link
Member

@SimonHeybrock SimonHeybrock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@@ -280,7 +280,8 @@ def parse_depends_on_chain(
chain.transformations[transform.name] = transform[()]
except KeyError as e:
warnings.warn(
UserWarning(f'depends_on chain references missing node {e}'), stacklevel=2
UserWarning(f'depends_on chain {depends_on} references missing node {e}'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No sure what this adds? I think the depends_on was already in the warning message as e?

Old error message: UserWarning: depends_on chain references missing node 'transform'
New error message: UserWarning: depends_on chain transform references missing node 'transform'

The KeyError is just the name of the missing entry.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's a lucky example, what I'm interested in is which node is causing the problem, and I get a message like so:

WARNING root:fileloading_test.py:31 UserWarning: depends_on chain /entry/instrument/detector_panel_2/transformations/stageZ references missing node 'depends_on'

Run against 443503_00032754.hdf

@@ -280,7 +280,8 @@ def parse_depends_on_chain(
chain.transformations[transform.name] = transform[()]
except KeyError as e:
warnings.warn(
UserWarning(f'depends_on chain references missing node {e}'), stacklevel=2
UserWarning(f'depends_on chain {depends_on} references missing node {e}'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI is complaining as the tests at

def test_compute_positions_warns_if_depends_on_is_dead_link(h5root):
instrument = snx.create_class(h5root, 'instrument', snx.NXinstrument)
detector = create_detector(instrument)
snx.create_field(detector, 'depends_on', sc.scalar('transform'))
root = make_group(h5root)
with pytest.warns(UserWarning, match='depends_on chain references missing node'):
loaded = root[()]
with pytest.warns(UserWarning, match='depends_on chain references missing node'):
snx.compute_positions(loaded)
also need to be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran it locally like so UserWarning(f'depends_on chain references missing node {e} {depends_on}'), and that was good enough for me then although it doesn't read as nicely. If that makes it easier to do the matching though you could do that, in case you match multiple warnings using wildcards

Copy link
Member

@nvaytet nvaytet Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace the match with match='depends_on chain .* references missing node' ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, let's see if it works

auto-merge was automatically disabled November 11, 2024 17:34

Head branch was pushed to by a user without write access

tests/nxtransformations_test.py Outdated Show resolved Hide resolved
tests/nxtransformations_test.py Outdated Show resolved Hide resolved
@nvaytet nvaytet merged commit 1dfd0f1 into scipp:main Nov 12, 2024
4 checks passed
@ggoneiESS ggoneiESS deleted the patch-1 branch November 13, 2024 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants