Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions scripts/create_new_beamline.py
Original file line number Diff line number Diff line change
@@ -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 = "TLA"


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 TLA",
pass_id=str(pass_ids[0]),
pass_name="Beamline 99-ID",
network_locations="xf99id1",
github_org="NSLS2",
service_accounts=ServiceAccounts(
ioc="softioc-tla",
epics_services="epics-tla",
workflow="workflow-tla",
bluesky="bluesky-tla",
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())
2 changes: 1 addition & 1 deletion src/nsls2api/services/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down