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

114 looks for errors in the structlogger in tests #115

Merged
merged 10 commits into from
Nov 19, 2024

Conversation

ka-sarthak
Copy link
Collaborator

Resolves #114

@ka-sarthak ka-sarthak self-assigned this Aug 28, 2024
@ka-sarthak ka-sarthak linked an issue Aug 28, 2024 that may be closed by this pull request
pyproject.toml Outdated
@@ -33,6 +33,7 @@ dev = [
"pytest",
"ruff",
"structlog==22.3.0",
"nomad-lab[infrastructure]>=1.3.4dev",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need the infrastructure dependencies?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Some of the dependencies from nomad are needed when running the cap log fixture, specifically:

    "python-logstash==0.4.6",
    "mongoengine>=0.20",
    "pyjwt[crypto]==2.6.0",
    "unidecode==1.3.2",
    "fastapi==0.92.0",
    "zipstream-new==1.1.5",

Since all of them were mentioned in the infrastructure, I thought of adding the full set to avoid future import errors if a new dependency is added, which the cap log fixture might require. However, we can also list only the dependencies that are currently required.

@ka-sarthak ka-sarthak force-pushed the 114-looks-for-errors-in-the-structlogger-in-tests branch 4 times, most recently from 564ea06 to b4b6696 Compare September 10, 2024 14:06
@ka-sarthak ka-sarthak force-pushed the 114-looks-for-errors-in-the-structlogger-in-tests branch from b4b6696 to cfa9126 Compare November 19, 2024 15:42
@ka-sarthak ka-sarthak force-pushed the 114-looks-for-errors-in-the-structlogger-in-tests branch from 1234047 to bb71620 Compare November 19, 2024 15:51
@ka-sarthak
Copy link
Collaborator Author

@hampusnasstrom I checked again if infra deps are still needed. Only one of them is required: python-logstash. Including this one as a dev dep. But otherwise, the PR is ready.

To test the caplog fixture, you can log an error in the normalize method. This should make the pytest fail.

For example, adding this:

logger.error('Error: here for testing')

here:

@ka-sarthak ka-sarthak force-pushed the 114-looks-for-errors-in-the-structlogger-in-tests branch from 1504c10 to 140ab7a Compare November 19, 2024 16:06
Copy link
Collaborator

@hampusnasstrom hampusnasstrom left a comment

Choose a reason for hiding this comment

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

Great!

@ka-sarthak ka-sarthak force-pushed the 114-looks-for-errors-in-the-structlogger-in-tests branch from 140ab7a to e5592f2 Compare November 19, 2024 16:22
@ka-sarthak ka-sarthak merged commit baa56e5 into main Nov 19, 2024
5 checks passed
@ka-sarthak ka-sarthak deleted the 114-looks-for-errors-in-the-structlogger-in-tests branch November 19, 2024 16:24
aalbino2 pushed a commit that referenced this pull request Dec 16, 2024
* Add fixture to capture error from logs

* Add nomad-lab infrastructure deps required by caplog fixture

* Ruff

* Refactoring fixtures; parameterize caplog to allow capturing different log levels

* Removing the formatter from nomad.utils

* testing: add logger.error in normalize

* testing: adding the formatter from nomad.utils

* Add logstash dep; cleaning

* Cleaning

* Specify caplog as an arg (from review)
aalbino2 added a commit that referenced this pull request Dec 19, 2024
* Added general PPMS plugin in its old structure

* Adapted PPMS structure

* Quick fix on the entry points

* Fix in schema bound_logger import

* Fixed formatting

* Fixed some typos

* Small Fix: ACT -> ETO

* changed names and made test folder

* added entrydata_definition for parser specilization

* lint

* Changed repeats to not is_scalar in merge_sections (#136)

Updated `merge_sections` util function to work with the latest nomad-lab version

* 137 merge sections break for non scalar quantities (#138)

* Added breaking test for boolean array

* Added more breaking test cases

* Added fix for comparing non numpy arrays

* Ruff

* Enhance test_merge_sections to capture output and validate float_array values

* Refine warning message for merging sections with differing quantity values

* Refactor merge_sections to improve warning logic for differing quantity values

* 139 merge sections still breaking for pint quantity arrays (#140)

* Added breaking test for float array with units

* Added fix for comparison of pint quantity arrays

* Added test for multi dimensional array

* Ruff

* 114 looks for errors in the structlogger in tests (#115)

* Add fixture to capture error from logs

* Add nomad-lab infrastructure deps required by caplog fixture

* Ruff

* Refactoring fixtures; parameterize caplog to allow capturing different log levels

* Removing the formatter from nomad.utils

* testing: add logger.error in normalize

* testing: adding the formatter from nomad.utils

* Add logstash dep; cleaning

* Cleaning

* Specify caplog as an arg (from review)

* moved nomad search import

* lint

* change create_archive inheritance

* lint

* fix test files path

* Added ETO test file to tests/ppms

* Added ETO sequence file to tests/ppms

* Changed regex in parsers mainfile_name_re

* Removed entry_type from PPMSSequenceParser

* lint

* Fixed PPMS parsers
Added call of set_entrydata_definition to parse

* Added test for PPMS data file

* Update __init__.py

* Fixed failing ppms test

* Fixed ppms test again

* PPMS data parser now matches two mime types

---------

Co-authored-by: Andrea Albino <andrea.albino@physik.hu-berlin.de>
Co-authored-by: Hampus Näsström <hampus.nasstrom@gmail.com>
Co-authored-by: Sarthak Kapoor <57119427+ka-sarthak@users.noreply.github.com>
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.

Looks for errors in the structlogger in tests
2 participants