Skip to content

Add backwards-compat alias for CONFIG singleton#2351

Merged
ml-evs merged 6 commits intomainfrom
ml-evs/singleton-config-alias
Feb 13, 2026
Merged

Add backwards-compat alias for CONFIG singleton#2351
ml-evs merged 6 commits intomainfrom
ml-evs/singleton-config-alias

Conversation

@ml-evs
Copy link
Member

@ml-evs ml-evs commented Feb 12, 2026

Attempts to address backwards compat issue originally posted by @DanielYang59 in #2313 (comment)_

@ml-evs ml-evs requested a review from CasperWA as a code owner February 12, 2026 18:03
@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.59%. Comparing base (e926d2e) to head (bbbf400).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
optimade/server/config.py 50.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2351      +/-   ##
==========================================
- Coverage   90.66%   90.59%   -0.07%     
==========================================
  Files          75       75              
  Lines        5022     5030       +8     
==========================================
+ Hits         4553     4557       +4     
- Misses        469      473       +4     
Flag Coverage Δ
project 90.59% <50.00%> (-0.07%) ⬇️
validator 90.59% <50.00%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@DanielYang59
Copy link

DanielYang59 commented Feb 12, 2026

Hi thanks for the quick fix but in our use case it's still not working (looks like some field provider_fields must have been changed from the model):

File "/home/yang/nomad/nomad-distro-dev/packages/nomad-FAIR/nomad/app/main.py", line 122, in <module>
    from .optimade import optimade_app
  File "/home/yang/nomad/nomad-distro-dev/packages/nomad-FAIR/nomad/app/optimade/__init__.py", line 117, in <module>
    CONFIG.provider_fields = dict(
    ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/yang/nomad/nomad-distro-dev/.venv/lib/python3.12/site-packages/pydantic/main.py", line 1033, in __setattr__
    setattr_handler(self, name, value)  # call here to not memo on possibly unknown fields
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/yang/nomad/nomad-distro-dev/.venv/lib/python3.12/site-packages/pydantic/main.py", line 111, in <lambda>
    'validate_assignment': lambda model, name, val: model.__pydantic_validator__.validate_assignment(model, name, val),  # pyright: ignore[reportAssignmentType]
                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1305 validation errors for ServerConfig
provider_fields.structures.0.str
  Input should be a valid string [type=string_type, input_value={'name': 'upload_id', 'de...ing', 'sortable': False}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type

@ml-evs
Copy link
Member Author

ml-evs commented Feb 12, 2026

One difference is that config vars are now validated on assignment, whereas before they were not, so likely you have some error in your config somewhere that has only just raised its head. By eye, it looks like only sortable should be added (I'm not sure if this metadata is even used anywhere, without looking) -- could you try again following my last commit? If that fails we can just remove the validation of provider field config for now, but an example of one of your provider fields would be helpful.

@DanielYang59
Copy link

DanielYang59 commented Feb 12, 2026

I'm not entirely sure because I didn't touch this part in NOMAD, but still got similar validation error:

  File "/home/yang/nomad/nomad-distro-dev/.venv/lib/python3.12/site-packages/pydantic/main.py", line 111, in <lambda>
    'validate_assignment': lambda model, name, val: model.__pydantic_validator__.validate_assignment(model, name, val),  # pyright: ignore[reportAssignmentType]
                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 870 validation errors for ServerConfig
provider_fields.structures.0.str
  Input should be a valid string [type=string_type, input_value={'name': 'upload_id', 'de...ing', 'sortable': False}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type

We could pin optimade<1.4.0 for now so no rush to disable validation, thanks!

@ml-evs
Copy link
Member Author

ml-evs commented Feb 12, 2026

Ok I see the issue (sortable is being provided as a bool but the type hint expects a string). There's no need for us to validate this so closely, so I've disabled it. If you could just check one more time then I'll merge and release this PR tonight.

@DanielYang59
Copy link

DanielYang59 commented Feb 12, 2026

I think some logger must have be renamed also, could be an issue from nomad side because logger shouldn't be considered public (I would look into this tomorrow)?

  File "/home/yang/nomad/nomad-distro-dev/packages/nomad-FAIR/nomad/app/main.py", line 122, in <module>
    from .optimade import optimade_app
  File "/home/yang/nomad/nomad-distro-dev/packages/nomad-FAIR/nomad/app/optimade/__init__.py", line 132, in <module>
    from optimade.server import main as optimade  # nopep8
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/yang/nomad/nomad-distro-dev/.venv/lib/python3.12/site-packages/optimade/server/main.py", line 8, in <module>
    from optimade.server.create_app import create_app
  File "/home/yang/nomad/nomad-distro-dev/.venv/lib/python3.12/site-packages/optimade/server/create_app.py", line 19, in <module>
    from optimade.server.exception_handlers import OPTIMADE_EXCEPTIONS
  File "/home/yang/nomad/nomad-distro-dev/.venv/lib/python3.12/site-packages/optimade/server/exception_handlers.py", line 12, in <module>
    from optimade.server.logger import get_logger
ImportError: cannot import name 'get_logger' from 'nomad.app.optimade_logger' (/home/yang/nomad/nomad-distro-dev/packages/nomad-FAIR/nomad/app/optimade_logger.py)

@ml-evs
Copy link
Member Author

ml-evs commented Feb 13, 2026

I think some logger must have be renamed also, could be an issue from nomad side because logger shouldn't be considered public (I would look into this tomorrow)?

  File "/home/yang/nomad/nomad-distro-dev/packages/nomad-FAIR/nomad/app/main.py", line 122, in <module>
    from .optimade import optimade_app
  File "/home/yang/nomad/nomad-distro-dev/packages/nomad-FAIR/nomad/app/optimade/__init__.py", line 132, in <module>
    from optimade.server import main as optimade  # nopep8
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/yang/nomad/nomad-distro-dev/.venv/lib/python3.12/site-packages/optimade/server/main.py", line 8, in <module>
    from optimade.server.create_app import create_app
  File "/home/yang/nomad/nomad-distro-dev/.venv/lib/python3.12/site-packages/optimade/server/create_app.py", line 19, in <module>
    from optimade.server.exception_handlers import OPTIMADE_EXCEPTIONS
  File "/home/yang/nomad/nomad-distro-dev/.venv/lib/python3.12/site-packages/optimade/server/exception_handlers.py", line 12, in <module>
    from optimade.server.logger import get_logger
ImportError: cannot import name 'get_logger' from 'nomad.app.optimade_logger' (/home/yang/nomad/nomad-distro-dev/packages/nomad-FAIR/nomad/app/optimade_logger.py)

get_logger was only added in #2313 so likely this is some namespace pollution on your end where you are importing some submodule with the alias optimade: from optimade.server import main as optimade # nopep8? There's no way we can easily undo that from our end. I'm going to merge and release this as 1.4.1 before other people potentially run into the config problem, but feel free to open a new issue if there's anything outstanding after fixing the logger at your end.

@ml-evs ml-evs merged commit d3307c1 into main Feb 13, 2026
12 of 13 checks passed
@ml-evs ml-evs deleted the ml-evs/singleton-config-alias branch February 13, 2026 10:53
@DanielYang59
Copy link

Thanks for the fix @fekad would get back to you a bit later as I'm not familiar with this part ;)

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.

2 participants