From 4e9d3e618710768d61eea695e7281193f66c60b0 Mon Sep 17 00:00:00 2001 From: Stuart Campbell Date: Mon, 13 Oct 2025 12:21:28 -0400 Subject: [PATCH 1/3] fix: change logger level to debug for unshared client calls --- src/nsls2api/services/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nsls2api/services/helpers.py b/src/nsls2api/services/helpers.py index 486a66d1..f8e02bae 100644 --- a/src/nsls2api/services/helpers.py +++ b/src/nsls2api/services/helpers.py @@ -56,7 +56,7 @@ async def _call_async_webservice( auth=auth, headers=headers, ) as client: - logger.logger(f"Calling {url} using unshared client.") + logger.debug(f"Calling {url} using unshared client.") resp: Response = await client.get(url) resp.raise_for_status() # if resp.status_code != 200: From 9f679e8256e22efd264ac7f0c4594e664793cdbb Mon Sep 17 00:00:00 2001 From: Stuart Campbell Date: Mon, 13 Oct 2025 12:21:46 -0400 Subject: [PATCH 2/3] feat: add script to create a new beamline in the database --- scripts/create_new_beamline.py | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 scripts/create_new_beamline.py diff --git a/scripts/create_new_beamline.py b/scripts/create_new_beamline.py new file mode 100644 index 00000000..09623187 --- /dev/null +++ b/scripts/create_new_beamline.py @@ -0,0 +1,49 @@ +import asyncio + +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 CREATE +BEAMLINE_NAME = "CDI" + + +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 len(pass_ids) > 1: + raise ValueError(f"Multiple pass IDs found for {BEAMLINE_NAME}: {pass_ids}") + + # CHANGE THESE VALUES TO SUIT YOUR NEEDS + new_beamline = Beamline( + name=BEAMLINE_NAME, + long_name="Fancy New Beamline", + alternative_name="99-ID", + port="99-ID", + nsls2_redhat_satellite_location_name="Beamlines/99-ID ABC", + pass_id=str(pass_ids[0]), + pass_name="Beamline 99-ID", + network_locations="xf99id1", + github_org="NSLS2", + service_accounts=ServiceAccounts( + ioc="softioc-abc", + epics_services="epics-abc", + workflow="workflow-abc", + bluesky="bluesky-abc", + operator="xf99id", + ), + ) + print(new_beamline) + + # Uncomment this line to actually insert the new beamline into the database + # await new_beamline.insert() + + +if __name__ == "__main__": + asyncio.run(main()) From a644a71ab283ae94cb1deaa30c24f67d7f0890f1 Mon Sep 17 00:00:00 2001 From: Stuart Campbell Date: Thu, 16 Oct 2025 08:08:54 -0400 Subject: [PATCH 3/3] Update to use TLA instead of ABC as a placeholder for the beamline name. --- scripts/create_new_beamline.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/create_new_beamline.py b/scripts/create_new_beamline.py index 09623187..b7cca736 100644 --- a/scripts/create_new_beamline.py +++ b/scripts/create_new_beamline.py @@ -8,7 +8,7 @@ settings = get_settings() # CHANGE THIS TO THE BEAMLINE YOU WANT TO CREATE -BEAMLINE_NAME = "CDI" +BEAMLINE_NAME = "TLA" async def main(): @@ -26,16 +26,16 @@ async def main(): long_name="Fancy New Beamline", alternative_name="99-ID", port="99-ID", - nsls2_redhat_satellite_location_name="Beamlines/99-ID ABC", + nsls2_redhat_satellite_location_name="Beamlines/99-ID TLA", pass_id=str(pass_ids[0]), pass_name="Beamline 99-ID", network_locations="xf99id1", github_org="NSLS2", service_accounts=ServiceAccounts( - ioc="softioc-abc", - epics_services="epics-abc", - workflow="workflow-abc", - bluesky="bluesky-abc", + ioc="softioc-tla", + epics_services="epics-tla", + workflow="workflow-tla", + bluesky="bluesky-tla", operator="xf99id", ), )