-
Notifications
You must be signed in to change notification settings - Fork 13
Added a script to update a beamline #235
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
padraic-shafer
merged 7 commits into
NSLS2:main
from
anubhutisinha04:update-service-accounts
Feb 5, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
73b9449
Added a script to update beamline
anubhutisinha04 43931c4
Review comments addressed.
anubhutisinha04 4760533
Removed hardcoded values from the script
anubhutisinha04 ddb0d90
Grammar improvement
anubhutisinha04 5e7b1ca
Removed redundant print statements and addressed review comments
anubhutisinha04 6052733
typo
anubhutisinha04 8160d83
typo number 2
anubhutisinha04 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 |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import asyncio | ||
| import datetime | ||
|
|
||
| from nsls2api.infrastructure import mongodb_setup | ||
| from nsls2api.infrastructure.config import get_settings | ||
| from nsls2api.models.beamlines import Beamline, ServiceAccounts | ||
| from nsls2api.services import pass_service | ||
|
|
||
| settings = get_settings() | ||
|
|
||
| # CHANGE THIS TO THE BEAMLINE YOU WANT TO UPDATE | ||
| BEAMLINE_NAME = "TLA" # Example: "HXN", "CDI", "AMX", etc. | ||
|
|
||
|
|
||
| async def main(): | ||
| # Initialize Beanie | ||
| await mongodb_setup.init_connection(settings.mongodb_dsn) | ||
|
|
||
| pass_resources = await pass_service.get_pass_resources() | ||
| pass_ids = [r["ID"] for r in pass_resources if r["Code"] == BEAMLINE_NAME] | ||
|
|
||
| if not pass_ids: | ||
| raise KeyError(f"No pass ID was found for {BEAMLINE_NAME}") | ||
|
|
||
| if len(pass_ids) > 1: | ||
| raise ValueError(f"Multiple pass IDs found for {BEAMLINE_NAME}: {pass_ids}") | ||
|
|
||
| beamline = await Beamline.find_one(Beamline.pass_id == str(pass_ids[0])) | ||
| if not beamline: | ||
| raise KeyError(f"No beamline found with pass_id {pass_ids[0]}") | ||
|
|
||
| print("Current beamline:") | ||
| print(beamline) | ||
anubhutisinha04 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # This is an example of updating the service accounts for the beamline. | ||
| # Change these values to suit your needs. | ||
| beamline.service_accounts = ServiceAccounts( | ||
| ioc="softioc-tla", | ||
| epics_services="epics-services-tla", | ||
| workflow="workflow-tla", | ||
| bluesky="bluesky-tla", | ||
| operator="xf99id", | ||
| lsdc=None | ||
| ) | ||
anubhutisinha04 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # INCLUDE ADDITIONAL CHANGES TO THE BEAMLINE OBJECT HERE AS NEEDED | ||
| # Example: beamline.long_name = "Repurposed Beamline" | ||
| # or: beamline.port = "99-BM" | ||
| # or: beamline.network_locations = "xf99bm1" | ||
|
|
||
| beamline.last_updated = datetime.datetime.now() | ||
|
|
||
| print("New values to be updated for the beamline:", beamline.name) | ||
| print(beamline) | ||
|
|
||
| # Uncomment the line below to actually save the changes to the database | ||
| # await beamline.save() | ||
anubhutisinha04 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if __name__ == "__main__": | ||
| asyncio.run(main()) | ||
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.
Uh oh!
There was an error while loading. Please reload this page.