-
Notifications
You must be signed in to change notification settings - Fork 1
Adds config files for the API #104
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
Merged
marcosfrenkel
merged 8 commits into
PublicQuantumNetwork:master
from
marcosfrenkel:config_file
Aug 18, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
57fdb6d
Adds config file support
marcosfrenkel 9b597f8
fixed renaming of duration
marcosfrenkel d10c60f
Ruff fixes
marcosfrenkel ff3455b
Removed @dataclass decorator from MeasurementConfig
marcosfrenkel bd7bbb6
Moved to base settings
marcosfrenkel c3f8201
Removed extra dotenv and moved configs
marcosfrenkel ec27bf8
Add lru_cache to Settings and update pydantic-settings version
marcosfrenkel e854456
moved lru_cache to correct function
marcosfrenkel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -165,4 +165,6 @@ cython_debug/ | |
| .vscode/ | ||
|
|
||
| # Mac Os | ||
| .DS_Store | ||
| .DS_Store | ||
|
|
||
| config.toml | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # MAKE SURE TO RENAME THIS FILE TO config.toml AND PLACE IT IN THE ROOT OF THE PROJECT | ||
|
|
||
| # Router configuration | ||
| router_name = "router1" | ||
| router_address = "xx.xx.xx.xx" # Replace with actual IP address | ||
| router_port = 5555 | ||
|
|
||
| # Timetagger configuration (provider_name, instrument_name) | ||
| timetagger = ["provider", "tagger"] # Replace with actual provider and instrument names | ||
|
|
||
| # Bell state configuration (default: Phi_plus) | ||
| bell_state = 0 | ||
|
|
||
| # CHSH experiment settings | ||
| [chsh_settings] | ||
| hwp = ["provider", "instrument_hwp"] # Replace with actual HWP names | ||
| request_hwp = ["provider", "instrument_hwp"] | ||
|
|
||
| # CHSH measurement configuration | ||
| [chsh_settings.measurement_config] | ||
| integration_time_s= 5 | ||
| binwidth = 500 | ||
| channel1 = 1 | ||
| channel2 = 2 | ||
| dark_count = 0 | ||
|
|
||
| # QKD experiment settings | ||
| [qkd_settings] | ||
| hwp = ["provider", "instrument_hwp"] | ||
| request_hwp = ["provider", "instrument_hwp"] | ||
| bitstring_length = 4 | ||
| discriminating_threshold = 10 | ||
|
|
||
| # QKD measurement configuration | ||
| [qkd_settings.measurement_config] | ||
| integration_time_s = 5 | ||
| binwidth = 500 | ||
| channel1 = 1 | ||
| channel2 = 2 | ||
| dark_count = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| [router] | ||
| name = "pqnstack-router" | ||
| host = "localhost" | ||
| port = 5556 | ||
|
|
||
| [provider] | ||
| name = "pqnstack-provider" | ||
| router_name = "pqnstack-router" | ||
| host = "localhost" | ||
| port = 5556 | ||
| beat_period = 2000 | ||
|
|
||
| [[provider.instruments]] | ||
| name = "dummy1" | ||
| import = "pqnstack.pqn.drivers.dummies.DummyInstrument" | ||
| desc = "Dummy instrument1 for testing purposes" | ||
| hw_address = "1234" | ||
|
|
||
| [[provider.instruments]] | ||
| name = "dummy2" | ||
| import = "pqnstack.pqn.drivers.dummies.DummyInstrument" | ||
| desc = "Dummy instrument2 for testing purposes" | ||
| hw_address = "1234" |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Consider using
@lru_cachefromfunctoolshttps://fastapi.tiangolo.com/advanced/settings/?h=settings#creating-the-settings-only-once-with-lru_cacheThere 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.
Since we are simply importing the settings object and using it there, the
get_settings()only gets called once already. I don't think most people know about that function so I don't want to add more complexity for basically no new functionalityUh oh!
There was an error while loading. Please reload this page.
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.
If we have dependencies with other endpoints in addition to the config, it might add to the complexity of why one is a (
Annotated)Dependsdpendency and another is directly imported. If we want to directly import, theget_settings()function itself is unnecessary; we can just instantiate theSettingsobject at the module level directly. But it makes more sense to me to stick to the FastAPI standard usingDepends, in which case I also recommend using@lru_cache.