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

Make error message from parsing more explicit #437

Merged
merged 7 commits into from
Jun 30, 2023

Conversation

Ananya2003Gupta
Copy link
Contributor

@Ananya2003Gupta Ananya2003Gupta commented Jun 29, 2023

BEGINRELEASENOTES

ENDRELEASENOTES
Solves Issue #436 : Misleading Error: Invalid Member Definition

Copy link
Collaborator

@tmadlener tmadlener left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of this. I triggered continuous integration (CI), and I have some minor suggestions below.

Comment on lines 102 to 103
self._parse_with_regexps(string, no_desc_matchers_cbs)
raise DefinitionError(f"'{string}' is not a valid member definition. Description (Comment after member definition) is missing. Correct Syntax: <type> <name> // <comment>") #require_description is set to True but member definition is missing description
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
self._parse_with_regexps(string, no_desc_matchers_cbs)
raise DefinitionError(f"'{string}' is not a valid member definition. Description (Comment after member definition) is missing. Correct Syntax: <type> <name> // <comment>") #require_description is set to True but member definition is missing description
# check whether we could parse this if we don't require a description and provide more details in the error if we can
self._parse_with_regexps(string, no_desc_matchers_cbs)
raise DefinitionError(f"'{string}' is not a valid member definition. Description comment is missing. Correct Syntax: <type> <name> // <comment>")

I would move the comment to the top of these lines, because people are more likely to find it there.

python/podio/podio_config_reader.py Show resolved Hide resolved
@tmadlener tmadlener linked an issue Jun 29, 2023 that may be closed by this pull request
@Ananya2003Gupta
Copy link
Contributor Author

Thanks for taking care of this. I triggered continuous integration (CI), and I have some minor suggestions below.

I didn't do anything. The additions were suggested by you only : )

@tmadlener
Copy link
Collaborator

It looks like our format and lint checks are not entirely happy yet:

https://github.com/AIDASoft/podio/actions/runs/5415352399/jobs/9843528142?pr=437#step:4:499

The rest looks fine. There is one workflow that is known to fail and which you can ignore in this case (key4hep).

@Ananya2003Gupta
Copy link
Contributor Author

It looks like our format and lint checks are not entirely happy yet:

https://github.com/AIDASoft/podio/actions/runs/5415352399/jobs/9843528142?pr=437#step:4:499

The rest looks fine. There is one workflow that is known to fail and which you can ignore in this case (key4hep).

Following errors are generated.

python/podio/podio_config_reader.py:89:13: E126 continuation line over-indented for hanging indent
  python/podio/podio_config_reader.py:91:9: E121 continuation line under-indented for hanging indent
  python/podio/podio_config_reader.py:94:21: E126 continuation line over-indented for hanging indent
  python/podio/podio_config_reader.py:96:7: E121 continuation line under-indented for hanging indent
  python/podio/podio_config_reader.py:103:121: E501 line too long (261 > 120 characters)
  python/podio/podio_config_reader.py:103:182: E262 inline comment should start with '# '

Copy link
Collaborator

@tmadlener tmadlener left a comment

Choose a reason for hiding this comment

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

You will have to fix the format issues to make that check happy. I have marked most of the occurrences below. If you have flake8 and pre-commit installed locally you can run pre-commit locally. You can also just do pre-commit run -a flake8 to just run the flake8 checks (which is much quicker than the full suite).

Comment on lines 89 to 90
(self.full_array_re, self._full_array_conv),
(self.member_re, self._full_member_conv)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here flake8 complains about too much indentation. So you will have to unindent these (to the same level they were before)

Comment on lines 94 to 96
(self.bare_array_re, self._bare_array_conv),
(self.bare_member_re, self._bare_member_conv)
]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here similar indentation issues are present.

Copy link
Collaborator

@tmadlener tmadlener left a comment

Choose a reason for hiding this comment

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

Thanks for fixing the formatting. I just realized that there are also some pylint warnings, which should be fixed by the comments below.

Comment on lines 100 to 101
"""check whether we could parse this if we don't require a description and
provide more details in the error if we can"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"""check whether we could parse this if we don't require a description and
provide more details in the error if we can"""
# check whether we could parse this if we don't require a description and
# provide more details in the error if we can

Otherwise pylint complains about a string statement without effect: log

python/podio/podio_config_reader.py Show resolved Hide resolved
Comment on lines 103 to 104
raise DefinitionError(f"""'{string}' is not a valid member definition. Description comment is missing.
Correct Syntax: <type> <name> // <comment>""")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
raise DefinitionError(f"""'{string}' is not a valid member definition. Description comment is missing.
Correct Syntax: <type> <name> // <comment>""")
raise DefinitionError(f"'{string}' is not a valid member definition. Description comment is missing."
" Correct Syntax: <type> <name> // <comment>")

You can also split strings this way and they will be concatenated. I find this a bit more readable.

@Ananya2003Gupta
Copy link
Contributor Author

Doing the above changes.
Really sorry. I just ran the flake8 tests and committed the changes.

Comment on lines 104 to 105
raise DefinitionError(f"'{string}' is not a valid member definition. Description comment is missing.\n"
+ "Correct Syntax: <type> <name> // <comment>")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
raise DefinitionError(f"'{string}' is not a valid member definition. Description comment is missing.\n"
+ "Correct Syntax: <type> <name> // <comment>")
raise DefinitionError(f"'{string}' is not a valid member definition. Description comment is missing."
" Correct Syntax: <type> <name> // <comment>")

You don't need the + in this case, and I would also not put in a newline (\n) to the output. Other than that this looks good.

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 put the newline character so that the error message looks good.
With newline character
image
Without newline character
image
Without newline character the error doesn't look good on screen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, I put a + for concatenation of string.

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK. I like the newline. But the + is not necessary for string concatenation in this case, because it will be done automatically inside the ().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I'll keep the newline character and remove + .

@tmadlener
Copy link
Collaborator

Just waiting for the last few workflows to finish, but they should be fine. Thanks again for all the work (and the patience in addressing my comments).

If I may ask: How did you get into contact with podio?

@Ananya2003Gupta
Copy link
Contributor Author

Ananya2003Gupta commented Jun 30, 2023

Just waiting for the last few workflows to finish, but they should be fine. Thanks again for all the work (and the patience in addressing my comments).

It was really fun working on this issue and I got to learn a lot about pre-commit through it.

If I may ask: How did you get into contact with podio?

I am selected as HSF India Trainee (IRIS HEP Fellow) and will be working on interfacing PODIO with Julia backend.

@tmadlener
Copy link
Collaborator

Ah very nice. We will be hearing more from you then :)

@Ananya2003Gupta
Copy link
Contributor Author

Ah very nice. We will be hearing more from you then :)

Yes : )

@tmadlener tmadlener changed the title Solves Issue #436 : Misleading Error: Invalid Member Definition Make error message from parsing more explicit Jun 30, 2023
@tmadlener tmadlener merged commit d8294d2 into AIDASoft:master Jun 30, 2023
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.

Misleading Error: Invalid Member Definition
2 participants