-
Notifications
You must be signed in to change notification settings - Fork 6
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
Config setup docs - through tests #634
Conversation
93899f7
to
4d6fbb3
Compare
4d6fbb3
to
4db0aa4
Compare
it works until line 179 ( call to |
config_data = {
"env": {},
"sources": [
{"kind": "dodal", "module": "dodal.adsim"},
{"kind": "planFunctions", "module": "dls_bluesky_core.plans"},
{"kind": "planFunctions", "module": "dls_bluesky_core.stubs"},
],
"data_writing": {
"visit_directory": "/dls/p38/data/2023/cm33874-1",
"group_name": "BL38P",
},
}
does not map directly to this: perhaps config loading could be simplified, to mirror more closely the helm structure |
all good |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #634 +/- ##
=======================================
Coverage 92.45% 92.46%
=======================================
Files 35 35
Lines 1657 1658 +1
=======================================
+ Hits 1532 1533 +1
Misses 125 125 ☔ View full report in Codecov by Sentry. |
class BasicAuthentication(BaseModel):
"""
User credentials for basic authentication
"""
username: str = Field(description="Unique identifier for user")
password: Secret[str] = Field(description="Password to verify user's identity")
@field_validator("username", "password", mode="before")
@classmethod
def get_from_env(cls, v: str):
if v.startswith("${") and v.endswith("}"):
return os.environ[v.removeprefix("${").removesuffix("}").upper()]
return v
current error is coming from |
@ZohebShaikh any ideas? |
@stan-dot you need to unwrap the Secret[str] before using it. It fetches it from the ENV if configured to do so for injection of the RMQ password. If you want to adjust how the handling of that env var fetching is done to your override levels handling then feel free. @keithralphs needs to mount a bunch of tracing values as env vars, so having that handling in one place is preferable. But the type of the password should remain |
f567ae7
to
59226b9
Compare
odd, digging deeper |
FAILED tests/unit_tests/test_config.py::test_config_yaml_parsed_complete[temp_yaml_config_file0] - blueapi.utils.invalid_config_error.InvalidConfigError: Something is wrong with the configuration file:
{'type': 'model_type', 'loc': ('scratch', 'repositories', 0), 'msg': 'Input should be a valid dictionary or instance of ScratchRepository', 'input': 'dodal', 'ctx': {'class_name': 'ScratchRepository'}, 'url': 'https://errors.pydantic.dev/2.9/v/model_type'}
FAILED tests/unit_tests/test_config.py::test_config_yaml_parsed_complete[temp_yaml_config_file1] - blueapi.utils.invalid_config_error.InvalidConfigError: Something is wrong with the configuration file:
{'type': 'model_type', 'loc': ('scratch', 'repositories', 0), 'msg': 'Input should be a valid dictionary or instance of ScratchRepository', 'input': 'dodal', 'ctx': {'class_name': 'ScratchRepository'}, 'url': 'https://errors.pydantic.dev/2.9/v/model_type'}
FAILED tests/unit_tests/worker/test_task_worker.py::test_worker_and_data_events_produce_in_order - concurrent.futures._base.TimeoutError
============= 3 failed,
got a more specific error |
2483a41
to
4c6ae93
Compare
tests/unit_tests/test_config.py
Outdated
# Parameterized test to run with different configurations | ||
# todo uncomment in python3.12, this here is for reference | ||
# type config_type = ( | ||
# dict[str, str | int | dict[str, str]] | ||
# | dict[str, dict[str, bool] | list[dict[str, str]]] | ||
# | dict[str, str | int] | ||
# | dict[str, str] | ||
# | dict[str, str | list[dict[str, str]]] | ||
# ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should: Uncomment and use or remove
fc9eec9
to
9c8fb85
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks
Co-authored-by: Callum Forrester <callum.forrester@diamond.ac.uk>
9c8fb85
to
326d1b1
Compare
please validate the directional correctness of the test first. #tdd