sirepo package

Submodules

sirepo.base_pkconfig module

Default config

copyright:Copyright (c) 2016 RadiaSoft LLC. All Rights Reserved.
license:http://www.apache.org/licenses/LICENSE-2.0.html
sirepo.base_pkconfig.alpha()[source]
sirepo.base_pkconfig.beta()[source]
sirepo.base_pkconfig.dev()[source]
sirepo.base_pkconfig.prod()[source]

sirepo.celery_tasks module

Celery tasks

copyright:Copyright (c) 2015 Bivio Software, Inc. All Rights Reserved.
license:http://www.apache.org/licenses/LICENSE-2.0.html
sirepo.celery_tasks.QUEUE_NAMES = ('sequential', 'parallel')

List of queues is indexed by “is_parallel”

sirepo.celery_tasks.queue_name(is_parallel)[source]

Which queue to execute in

Parameters:is_parallel (bool) – is it a parallel job?
Returns:name of queue to route task
Return type:str

sirepo.crystal module

Get polarizability from X0h server (http://x-server.gmca.aps.anl.gov/x0h.html). For details see http://x-server.gmca.aps.anl.gov/pub/Stepanov_CR_1991_08.pdf.

sirepo.crystal.calc_bragg_angle(d, energy_eV, n=1)[source]

Calculate Bragg angle from the provided energy and d-spacing.

Parameters:
  • d (float) – interplanar spacing (d-spacing) [A].
  • energy_eV (float) – photon energy [eV].
  • n (int) – number of diffraction peak.
Returns:

the resulted dictionary with: lamda (float): wavelength [nm]. bragg_angle (float): Bragg angle [rad]. bragg_angle_deg (float): Bragg angle [deg].

Return type:

dict

sirepo.crystal.get_crystal_parameters(material, energy_eV, h, k, l)[source]

Obtain parameters for the specified crystal and energy.

Parameters:
  • material (str) – material full name (e.g., ‘Silicon’).
  • energy_eV (float) – photon energy [eV].
  • h (int) – Miller’s index h.
  • k (int) – Miller’s index k.
  • l (int) – Miller’s index l.
Returns:

crystal parameters: d (float): interplanar spacing (d-spacing) [A]. xr0 (float): real part of the 0-th Fourier component of crystal’s polarizability. xi0 (float): imaginary part of the 0-th Fourier component of crystal’s polarizability. xrh (float): real part of the H-th Fourier component of crystal’s polarizability (Sigma polarization). xih (float): imaginary part of the H-th Fourier component of crystal’s polarizability (Sigma polarization). bragg_angle_deg (float): Bragg angle [deg].

Return type:

dict

sirepo.exporter module

Export simulations in a single archive

copyright:Copyright (c) 2017 RadiaSoft LLC. All Rights Reserved.
license:http://www.apache.org/licenses/LICENSE-2.0.html
sirepo.exporter.create_archive(sim_type, sim_id, filename)[source]

Zip up the json file and its dependencies

Parameters:
  • sim_type (str) – simulation type
  • sim_id (str) – simulation id
  • filename (str) – for file type
Returns:

zip file name

Return type:

py.path.Local

sirepo.feature_config module

List of features available

copyright:Copyright (c) 2016 RadiaSoft LLC. All Rights Reserved.
license:http://www.apache.org/licenses/LICENSE-2.0.html
sirepo.feature_config.cfg = OrderedMapping(sim_types=('srw', 'warppba', 'elegant', 'shadow', 'hellweg', 'warpvnd', 'rs4pi'), srw=OrderedMapping(mask_in_toolbar=True))

Configuration

sirepo.feature_config.for_sim_type(sim_type)[source]

Get cfg for simulation type

Parameters:sim_type (str) – srw, warppba, etc.
Returns:application specific config
Return type:dict

sirepo.importer module

Import a single archive

copyright:Copyright (c) 2017 RadiaSoft LLC. All Rights Reserved.
license:http://www.apache.org/licenses/LICENSE-2.0.html
sirepo.importer.do_form(form)[source]

Self-extracting archive post

Parameters:form (flask.request.Form) – what to import
Returns:data
Return type:dict
sirepo.importer.read_json(text, template=None)[source]

Read json file and return

Parameters:
  • text (IO) – file to be read
  • template (module) – expected type
Returns:

data

Return type:

dict

sirepo.importer.read_zip(stream, template=None)[source]

Read zip file and store contents

Parameters:
  • stream (IO) – file to read
  • template (module) – expected app
Returns:

data

Return type:

dict

sirepo.mpi module

Run Python processes in background

copyright:Copyright (c) 2016 RadiaSoft LLC. All Rights Reserved.
license:http://www.apache.org/licenses/LICENSE-2.0.html
sirepo.mpi.run_program(cmd, output='mpi_run.out', env=None)[source]

Execute python script with mpi.

Parameters:
  • cmd (list) – cmd to run
  • output (str) – where to write stdout and stderr
  • env (dict) – what to pass as env
sirepo.mpi.run_script(script)[source]

Execute python script with mpi.

Parameters:script (str) – python text

sirepo.oauth module

sirepo.runner module

Run jobs

copyright:Copyright (c) 2016 RadiaSoft LLC. All Rights Reserved.
license:http://www.apache.org/licenses/LICENSE-2.0.html
class sirepo.runner.Background(data)[source]

Bases: object

Run as subprocess

classmethod is_processing(jid)[source]
classmethod kill(jid)[source]
classmethod race_condition_reap(jid)[source]

Job terminated, but not still in queue.

This can happen due to race condition in is_processing. Call again to remove the job from the queue.

classmethod sigchld_handler(signum=None, frame=None)[source]
class sirepo.runner.Celery(data)[source]

Bases: object

Run job in Celery (prod)

classmethod is_processing(jid)[source]

Job is either in the queue or running

classmethod kill(jid)[source]
classmethod race_condition_reap(jid)[source]

Race condition due to lack of mutex and reliable results.

exception sirepo.runner.Collision[source]

Bases: exceptions.Exception

Avoid using a mutex

sirepo.runner.cfg_job_queue(value)[source]

Return job queue class based on name

Parameters:value (object) – May be class or str.
Returns:Background or Celery class.
Return type:object

sirepo.server module

Flask routes

copyright:Copyright (c) 2015 RadiaSoft LLC. All Rights Reserved.
license:http://www.apache.org/licenses/LICENSE-2.0.html
sirepo.server.SR_UNIT_TEST_IN_REQUEST = 'test_in_request'

See sirepo.sr_unit

sirepo.server.all_uids()[source]

List of all users

Returns:set of all uids
Return type:set
sirepo.server.api_copyNonSessionSimulation()[source]
sirepo.server.api_copySimulation()[source]

Takes the specified simulation and returns a newly named copy with the suffix (copy X)

sirepo.server.api_deleteFile()[source]
sirepo.server.api_deleteSimulation()[source]
sirepo.server.api_downloadDataFile(simulation_type, simulation_id, model, frame, suffix=None)[source]
sirepo.server.api_downloadFile(simulation_type, simulation_id, filename)[source]
sirepo.server.api_errorLogging()[source]
sirepo.server.api_exportArchive(simulation_type, simulation_id, filename)[source]
sirepo.server.api_favicon()[source]

Routes to favicon.ico file.

sirepo.server.api_findByName(simulation_type, application_mode, simulation_name)[source]
sirepo.server.api_getApplicationData(filename='')[source]

Get some data from the template

Parameters:filename (str) – if supplied, result is file attachment
Returns:may be a file or JSON
Return type:response
sirepo.server.api_homePage()[source]
sirepo.server.api_importArchive()[source]
Parameters:simulation_type (str) – which simulation type
Params:
data: what to import
sirepo.server.api_importFile(simulation_type=None)[source]
Parameters:simulation_type (str) – which simulation type
Params:
file: file data folder: where to import to
sirepo.server.api_listFiles(simulation_type, simulation_id, file_type)[source]
sirepo.server.api_listSimulations()[source]
sirepo.server.api_newSimulation()[source]
sirepo.server.api_oauthAuthorized(oauth_type)[source]
sirepo.server.api_oauthLogin(simulation_type, oauth_type)[source]
sirepo.server.api_oauthLogout(simulation_type)[source]
sirepo.server.api_pythonSource(simulation_type, simulation_id, model=None)[source]
sirepo.server.api_robotsTxt()[source]

Tell robots to go away

sirepo.server.api_root(simulation_type)[source]
sirepo.server.api_runCancel()[source]
sirepo.server.api_runSimulation()[source]
sirepo.server.api_runStatus()[source]
sirepo.server.api_saveSimulationData()[source]
sirepo.server.api_simulationData(simulation_type, simulation_id, pretty)[source]
sirepo.server.api_simulationFrame(frame_id)[source]
sirepo.server.api_simulationSchema()[source]
sirepo.server.api_srLandingPage()[source]
sirepo.server.api_srUnit()[source]
sirepo.server.api_updateFolder()[source]
sirepo.server.api_uploadFile(simulation_type, simulation_id, file_type)[source]
sirepo.server.app = <Flask 'sirepo.server'>

Flask app instance, must be bound globally

sirepo.server.app_copy_nonsession_simulation()
sirepo.server.app_copy_simulation()

Takes the specified simulation and returns a newly named copy with the suffix (copy X)

sirepo.server.app_delete_file()
sirepo.server.app_delete_simulation()
sirepo.server.app_download_data_file(simulation_type, simulation_id, model, frame, suffix=None)
sirepo.server.app_download_file(simulation_type, simulation_id, filename)
sirepo.server.app_error_logging()
sirepo.server.app_favicon()

Routes to favicon.ico file.

sirepo.server.app_file_list(simulation_type, simulation_id, file_type)
sirepo.server.app_find_by_name(simulation_type, application_mode, simulation_name)
sirepo.server.app_get_application_data(filename='')

Get some data from the template

Parameters:filename (str) – if supplied, result is file attachment
Returns:may be a file or JSON
Return type:response
sirepo.server.app_import_file(simulation_type=None)
Parameters:simulation_type (str) – which simulation type
Params:
file: file data folder: where to import to
sirepo.server.app_new_simulation()
sirepo.server.app_oauth_authorized(oauth_type)
sirepo.server.app_oauth_login(simulation_type, oauth_type)
sirepo.server.app_oauth_logout(simulation_type)
sirepo.server.app_python_source(simulation_type, simulation_id, model=None)
sirepo.server.app_robots_txt()

Tell robots to go away

sirepo.server.app_root(simulation_type)
sirepo.server.app_run_cancel()
sirepo.server.app_run_simulation()
sirepo.server.app_run_status()
sirepo.server.app_save_simulation_data()
sirepo.server.app_simulation_data(simulation_type, simulation_id, pretty)
sirepo.server.app_simulation_frame(frame_id)
sirepo.server.app_simulation_list()
sirepo.server.app_simulation_schema()
sirepo.server.app_sr_unit()
sirepo.server.app_update_folder()
sirepo.server.app_upload_file(simulation_type, simulation_id, file_type)
sirepo.server.clear_session_user()[source]

Remove the current user from the flask session.

sirepo.server.init(db_dir=None, uwsgi=None)[source]

Initialize globals and populate simulation dir

sirepo.server.javascript_redirect(redirect_uri)[source]

Redirect using javascript for safari browser which doesn’t support hash redirects.

sirepo.server.light_landing_page()
sirepo.server.session_user(*args, **kwargs)[source]

Get/set the user from the Flask session

With no positional arguments, is a getter. Else a setter.

Parameters:
  • user (str) – if args[0], will set the user; else gets
  • checked (bool) – if kwargs[‘checked’], assert the user is truthy
  • environ (dict) – session environment to use instead of flask.session
Returns:

user id

Return type:

str

sirepo.server.sr_landing_page()

sirepo.simulation_db module

Simulation database

copyright:Copyright (c) 2015 RadiaSoft LLC. All Rights Reserved.
license:http://www.apache.org/licenses/LICENSE-2.0.html
exception sirepo.simulation_db.CopyRedirect(response)[source]

Bases: exceptions.Exception

sirepo.simulation_db.JSON_SUFFIX = '.json'

Json files

sirepo.simulation_db.SCHEMA_COMMON = {u'appInfo': {u'warpvnd': {u'shortName': u'Warp VND', u'longName': u'Warp VND'}, u'rs4pi': {u'shortName': u'RS4PI', u'longName': u'RS4PI'}, u'elegant': {u'shortName': u'Elegant', u'longName': u'elegant'}, u'srw': {u'shortName': u'SRW', u'longName': u'Synchrotron Radiation Workshop'}, u'shadow': {u'shortName': u'SHADOW', u'longName': u'SHADOW'}, u'hellweg': {u'shortName': u'Hellweg', u'longName': u'Hellweg'}, u'warppba': {u'shortName': u'Warp PBA', u'longName': u'Warp PBA'}}, u'route': {u'importFile': u'/import-file/?<simulation_type>', u'getApplicationData': u'/get-application-data/?<filename>', u'robotsTxt': u'/robots.txt', u'copyNonSessionSimulation': u'/copy-non-session-simulation', u'downloadFile': u'/download-file/<simulation_type>/<simulation_id>/<filename>', u'favicon': u'/favicon.ico', u'simulationSchema': u'/simulation-schema', u'pythonSource': u'/python-source/<simulation_type>/<simulation_id>/?<model>', u'copySimulation': u'/copy-simulation', u'updateFolder': u'/update-folder', u'listSimulations': u'/simulation-list', u'homePage': u'/light', u'findByName': u'/find-by-name/<simulation_type>/<application_mode>/<simulation_name>', u'oauthLogin': u'/login/<simulation_type>/<oauth_type>', u'simulationFrame': u'/simulation-frame/<frame_id>', u'uploadFile': u'/upload-file/<simulation_type>/<simulation_id>/<file_type>', u'errorLogging': u'/error-logging', u'srUnit': u'/ sr_unit', u'deleteFile': u'/delete-file', u'oauthAuthorized': u'/oauth-authorized/<oauth_type>', u'listFiles': u'/file-list/<simulation_type>/<simulation_id>/<file_type>', u'saveSimulationData': u'/save-simulation', u'srLandingPage': u'/sr', u'downloadDataFile': u'/download-data-file/<simulation_type>/<simulation_id>/<model>/<frame>/?<suffix>', u'runStatus': u'/run-status', u'importArchive': u'/import-archive', u'simulationData': u'/simulation/<simulation_type>/<simulation_id>/<pretty>', u'deleteSimulation': u'/delete-simulation', u'runSimulation': u'/run-simulation', u'exportArchive': u'/export-archive/<simulation_type>/<simulation_id>/<filename>', u'newSimulation': u'/new-simulation', u'oauthLogout': u'/logout/<simulation_type>', u'runCancel': u'/run-cancel', u'root': u'/<simulation_type>'}, u'commonModels': {u'simFolder': {u'name': [u'Folder Name', u'SafePath']}, u'simulation': {u'documentationUrl': [u'Documentation URL', u'OptionalString', u''], u'folder': [u'Folder', u'String'], u'name': [u'Name', u'SafePath']}}, u'productInfo': {u'shortName': u'Sirepo', u'longName': u'Sirepo'}, u'version': u'20171017.000002', u'commonViews': {u'simFolder': {u'advanced': [u'name'], u'title': u'New Folder'}, u'simDoc': {u'model': u'simulation', u'advanced': [u'documentationUrl'], u'title': u'Simulation Documentation'}}}

Schema common values, e.g. version

sirepo.simulation_db.SIMULATION_DATA_FILE = 'sirepo-data.json'

Simulation file name is globally unique to avoid collisions with simulation output

sirepo.simulation_db.STATIC_FOLDER = local('/home/docs/checkouts/readthedocs.org/user_builds/sirepo/checkouts/latest/sirepo/package_data/static')

Where server files and static files are found

sirepo.simulation_db.app_version()[source]

Force the version to be dynamic if running in dev channel

Returns:chronological version
Return type:str
sirepo.simulation_db.celery_queue(data)[source]

Which queue to execute simulation in

Parameters:data (dict) – simulation parameters
Returns:celery queue name
Return type:str
sirepo.simulation_db.cfg = OrderedMapping(nfs_sleep=0.5, nfs_tries=10)

configuration

sirepo.simulation_db.default_data(sim_type)[source]

New simulation base data

Parameters:sim_type (str) – simulation type
Returns:simulation data
Return type:dict
sirepo.simulation_db.delete_simulation(simulation_type, sid)[source]

Deletes the simulation’s directory.

sirepo.simulation_db.examples(app)[source]
sirepo.simulation_db.find_global_simulation(simulation_type, sid)[source]
sirepo.simulation_db.fixup_old_data(data, force=False)[source]

Upgrade data to latest schema and updates version.

Parameters:
  • data (dict) – to be updated (destructively)
  • force (bool) – force validation
Returns:

upgraded data bool: True if data changed

Return type:

dict

sirepo.simulation_db.generate_json(data, pretty=False)[source]

Convert data to JSON to be send back to client

Use only for responses. Use :func:write_json to save. :param data: what to format :type data: dict :param pretty: pretty print [False] :type pretty: bool

Returns:formatted data
Return type:str
sirepo.simulation_db.get_schema(sim_type)[source]
sirepo.simulation_db.hack_nfs_write_status(status, run_dir)[source]

Verify status file exists before writing.

NFS doesn’t propagate files immediately so there is a race condition when the celery worker starts. This file handles this case.

Parameters:
  • status (str) – pending, running, completed, canceled
  • run_dir (py.path) – where to write the file
sirepo.simulation_db.init_by_server(app, server)[source]

Avoid circular import by explicit call from sirepo.server.

Parameters:
  • app (Flask) – flask instance
  • server (module) – sirepo.server
sirepo.simulation_db.is_parallel(data)[source]

Is this report a parallel (long) simulation?

Parameters:data (dict) – report and models
Returns:True if parallel job
Return type:bool
sirepo.simulation_db.iterate_simulation_datafiles(simulation_type, op, search=None)[source]
sirepo.simulation_db.job_id(data)[source]

A Job is a simulation and report name

Parameters:data (dict) – extract sid and report
Returns:unique name
Return type:str
sirepo.simulation_db.json_filename(filename, run_dir=None)[source]

Append JSON_SUFFIX if necessary and convert to str

Parameters:
  • filename (py.path or str) – to convert
  • run_dir (py.path) – which directory to joing
Returns:

filename.json

Return type:

py.path

sirepo.simulation_db.json_load(*args, **kwargs)[source]
sirepo.simulation_db.move_user_simulations(to_uid)[source]

Moves all non-example simulations for the current session into the target user’s dir.

sirepo.simulation_db.open_json_file(sim_type, path=None, sid=None, fixup=True)[source]

Read a db file and return result

Parameters:
  • sim_type (str) – simulation type (app)
  • path (py.path.local) – where to read the file
  • sid (str) – simulation id
Returns:

data

Return type:

dict

Raises:

CopyRedirect – if the simulation is in another user’s

sirepo.simulation_db.parse_sid(data)[source]

Extract id from data

Parameters:data (dict) – models or request
Returns:simulationId from data
Return type:str
sirepo.simulation_db.parse_sim_ser(data)[source]

Extract simulationStatus from data

Parameters:data (dict) – models or request
Returns:simulationSerial
Return type:int
sirepo.simulation_db.poll_seconds(data)[source]

Client poll period for simulation status

TODO(robnagler) needs to be encapsulated

Parameters:data (dict) – must container report name
Returns:number of seconds to poll
Return type:int
sirepo.simulation_db.prepare_simulation(data)[source]

Create and install files, update parameters, and generate command.

Copies files into the simulation directory (run_dir). Updates the parameters in data and save. Generate the pkcli command to pass to task runner.

Parameters:data (dict) – report and model parameters
Returns:pkcli command, simulation directory
Return type:list, py.path
sirepo.simulation_db.process_simulation_list(res, path, data)[source]
sirepo.simulation_db.read_json(filename)[source]

Read data from json file

Parameters:filename (py.path or str) – will append JSON_SUFFIX if necessary
Returns:json converted to python
Return type:object
sirepo.simulation_db.read_result(run_dir)[source]

Read result data file from simulation

Parameters:run_dir (py.path) – where to find output
Returns:result or describes error
Return type:dict
sirepo.simulation_db.read_simulation_json(sim_type, *args, **kwargs)[source]

Calls open_json_file and fixes up data, possibly saving

Parameters:sim_type (str) – simulation type
Returns:data – simulation data
Return type:dict
sirepo.simulation_db.read_status(run_dir)[source]

Read status from simulation dir

Parameters:run_dir (py.path) – where to read
sirepo.simulation_db.report_info(data)[source]

Read the run_dir and return cached_data.

Only a hit if the models between data and cache match exactly. Otherwise, return cached data if it’s there and valid.

Parameters:data (dict) – parameters identifying run_dir and models or reportParametersHash
Returns:report parameters and hashes
Return type:Dict
sirepo.simulation_db.save_new_example(data)[source]
sirepo.simulation_db.save_new_simulation(data)[source]
sirepo.simulation_db.save_simulation_json(data)[source]

Prepare data and save to json db

Parameters:data (dict) – what to write (contains simulationId)
sirepo.simulation_db.sim_data_file(sim_type, sim_id)[source]

Simulation data file name

Parameters:
  • sim_type (str) – simulation type
  • sim_id (str) – simulation id
Returns:

simulation path

Return type:

py.path.local

sirepo.simulation_db.simulation_dir(simulation_type, sid=None)[source]

Generates simulation directory from sid and simulation_type

Parameters:
  • simulation_type (str) – srw, warppba, ...
  • sid (str) – simulation id (optional)
sirepo.simulation_db.simulation_lib_dir(simulation_type)[source]

String name for user library dir

Parameters:simulation_type – which app is this for
Returns:directory name
Return type:py.path
sirepo.simulation_db.simulation_run_dir(data, remove_dir=False)[source]

Where to run the simulation

Parameters:
  • data (dict) – contains simulationType and simulationId
  • remove_dir (bool) – remove the directory [False]
Returns:

directory to run

Return type:

py.path

sirepo.simulation_db.simulation_type_from_dir_name(d)[source]

Extract simulation_type from simulation_dir

sirepo.simulation_db.tmp_dir()[source]

Generates new, temporary directory

Returns:directory to use for temporary work
Return type:py.path
sirepo.simulation_db.uid_from_dir_name(dir_name)[source]

Extra user id from user_dir_name

Parameters:dir_name (py.path) – must be top level user dir
Returns:user id
Return type:str
sirepo.simulation_db.user_dir_name(uid=None)[source]

String name for user name

Parameters:uid (str) – properly formated user name (optional)
Returns:directory name
Return type:py.path
sirepo.simulation_db.validate_serial(req_data)[source]

Verify serial in data validates

Parameters:req_data (dict) – request with serial and possibly models
Returns:None if all ok, or json response (bad)
Return type:object
sirepo.simulation_db.verify_app_directory(simulation_type)[source]

Ensure the app directory is present. If not, create it and add example files.

sirepo.simulation_db.write_json(filename, data)[source]

Write data as json to filename

Parameters:filename (py.path or str) – will append JSON_SUFFIX if necessary
sirepo.simulation_db.write_result(result, run_dir=None)[source]

Write simulation result to standard output.

Parameters:
  • result (dict) – will set state to completed
  • run_dir (py.path) – Defaults to current dir
sirepo.simulation_db.write_status(status, run_dir)[source]

Write status to simulation

Parameters:
  • status (str) – pending, running, completed, canceled
  • run_dir (py.path) – where to write the file

sirepo.sirepo_console module

SiRepo front-end command line for pykern.pkcli.

Example:

copyright:Copyright (c) 2015 RadiaSoft LLC. All Rights Reserved.
license:http://www.apache.org/licenses/LICENSE-2.0.html
sirepo.sirepo_console.main()[source]

sirepo.sr_unit module

Support for unit tests

copyright:Copyright (c) 2016 RadiaSoft LLC. All Rights Reserved.
license:http://www.apache.org/licenses/LICENSE-2.0.html
sirepo.sr_unit.flask_client()[source]

Return FlaskClient with easy access methods.

Creates a new run directory every test file so can assume sharing of state on the server within a file (module).

Two methods of interest: sr_post and sr_get.

Returns:for local requests to Flask server
Return type:FlaskClient
sirepo.sr_unit.init_user_db()[source]

Force a request that creates a user in db

sirepo.sr_unit.server = None

import sirepo.server

sirepo.sr_unit.test_in_request(op)[source]

sirepo.uri_router module

Handles dispatching of uris to server.api_* functions

copyright:Copyright (c) 2017 RadiaSoft LLC. All Rights Reserved.
license:http://www.apache.org/licenses/LICENSE-2.0.html
exception sirepo.uri_router.NotFound(log_fmt, *args, **kwargs)[source]

Bases: exceptions.Exception

Raised to indicate page not found exception (404)

sirepo.uri_router.api_for_func(func)[source]

Returns api name for given function

Parameters:func (code) – for __name__
Returns:name of api
Return type:str
sirepo.uri_router.func_for_api(api_name, api_module)[source]

Returns func for given api name and module

Parameters:
  • api_name (str) – camelCase
  • api_module (module) – where from
Returns:

what to call

Return type:

code

sirepo.uri_router.init(app, api_module, simulation_db)[source]

Convert route map to dispatchable callables

Initializes _uri_to_route and adds a single flask route (_dispatch) to dispatch based on the map.

Parameters:
  • app (Flask) – flask app
  • api_module (module) – where to get callables
sirepo.uri_router.sr_unit_uri = None

route for sirepo.sr_unit

sirepo.uri_router.uri_for_api(api_name, params=None, external=True)[source]

Generate uri for api method

Parameters:
  • api_name (str) – full name of api
  • params (str) – paramters to pass to uri
  • external (bool) – external uri? [True]
Returns:

formmatted external URI

Return type:

str

Module contents