sirepo package¶
sirepo package
- copyright:
Copyright (c) 2018-2024 RadiaSoft LLC.. All Rights Reserved.
- license:
Subpackages¶
- sirepo.analysis package
- sirepo.auth package
- sirepo.auth_db package
db_filename()get_class()init_module()init_quest()primary_key_column()- Submodules
- sirepo.auth_db.base module
- sirepo.auth_db.email module
- sirepo.auth_db.jupyterhub module
- sirepo.auth_db.stripe module
StripePaymentStripeSubscriptionStripeSubscription.checkout_session_idStripeSubscription.createdStripeSubscription.creation_reasonStripeSubscription.customer_idStripeSubscription.not_revoked_stripe_subscriptions()StripeSubscription.revocation_reasonStripeSubscription.revoke_due_to_inactive_stripe_status()StripeSubscription.revokedStripeSubscription.roleStripeSubscription.stripe_subscription_keyStripeSubscription.subscription_idStripeSubscription.uid
- sirepo.auth_db.user module
UserRegistrationUserRoleUserRole.add_plan()UserRole.add_roles()UserRole.all_roles()UserRole.delete_roles()UserRole.expirationUserRole.expire_role()UserRole.get_roles()UserRole.get_roles_and_expiration()UserRole.has_active_plan()UserRole.has_active_role()UserRole.has_expired_role()UserRole.roleUserRole.set_role_expiration()UserRole.uidUserRole.uids_of_paid_users()UserRole.uids_with_roles()UserRole.unchecked_active_plan()
UserRoleModeration
- sirepo.global_resources package
- sirepo.job_driver package
- sirepo.pkcli package
import_module()- Submodules
- sirepo.pkcli.activait module
- sirepo.pkcli.admin module
- sirepo.pkcli.auth module
- sirepo.pkcli.canvas module
- sirepo.pkcli.controls module
- sirepo.pkcli.cortex module
- sirepo.pkcli.dev module
- sirepo.pkcli.devtools module
- sirepo.pkcli.elegant module
- sirepo.pkcli.elegant_schema module
- sirepo.pkcli.epicsllrf module
- sirepo.pkcli.flash module
- sirepo.pkcli.genesis module
- sirepo.pkcli.hellweg module
- sirepo.pkcli.impactt module
- sirepo.pkcli.impactx module
- sirepo.pkcli.job_agent module
- sirepo.pkcli.job_cmd module
- sirepo.pkcli.job_supervisor module
- sirepo.pkcli.jspec module
- sirepo.pkcli.jupyterhublogin module
- sirepo.pkcli.madx module
- sirepo.pkcli.madx_device_server module
- sirepo.pkcli.myapp module
- sirepo.pkcli.nersc_test module
- sirepo.pkcli.omega module
- sirepo.pkcli.opal module
- sirepo.pkcli.openmc module
- sirepo.pkcli.radia module
- sirepo.pkcli.raydata module
- sirepo.pkcli.roles module
- sirepo.pkcli.service module
- sirepo.pkcli.setup_dev module
- sirepo.pkcli.shadow module
- sirepo.pkcli.silas module
- sirepo.pkcli.sim_data module
- sirepo.pkcli.srw module
- sirepo.pkcli.static_files module
- sirepo.pkcli.test_http module
- sirepo.pkcli.warppba module
- sirepo.pkcli.warpvnd module
- sirepo.pkcli.zgoubi module
- sirepo.raydata package
- sirepo.sim_api package
- sirepo.sim_data package
SimDataBaseSimDataBase.ANALYSIS_ONLY_FIELDSSimDataBase.LIB_DIRSimDataBase.WATCHPOINT_REPORTSimDataBase.WATCHPOINT_REPORT_RESimDataBase.compute_job_hash()SimDataBase.compute_model()SimDataBase.does_api_reply_with_file()SimDataBase.example_paths()SimDataBase.fixup_old_data()SimDataBase.frame_id()SimDataBase.is_parallel()SimDataBase.is_run_mpi()SimDataBase.is_watchpoint()SimDataBase.lib_file_abspath()SimDataBase.lib_file_basenames()SimDataBase.lib_file_exists()SimDataBase.lib_file_in_use()SimDataBase.lib_file_is_zip()SimDataBase.lib_file_name_with_model_field()SimDataBase.lib_file_name_with_type()SimDataBase.lib_file_name_without_type()SimDataBase.lib_file_names_for_type()SimDataBase.lib_file_read_binary()SimDataBase.lib_file_read_text()SimDataBase.lib_file_resource_path()SimDataBase.lib_file_save_from_url()SimDataBase.lib_file_size()SimDataBase.lib_file_write()SimDataBase.lib_file_write_path()SimDataBase.lib_files_for_export()SimDataBase.lib_files_from_other_user()SimDataBase.lib_files_to_run_dir()SimDataBase.model_defaults()SimDataBase.parse_jid()SimDataBase.parse_model()SimDataBase.parse_sid()SimDataBase.poll_seconds()SimDataBase.prepare_import_file_args()SimDataBase.proprietary_code_lib_file_basenames()SimDataBase.proprietary_code_tarball()SimDataBase.put_sim_file()SimDataBase.resource_path()SimDataBase.schema()SimDataBase.sim_db_client()SimDataBase.sim_db_read_sim()SimDataBase.sim_db_save_sim()SimDataBase.sim_file_basenames()SimDataBase.sim_files_to_run_dir()SimDataBase.sim_run_dir_prepare()SimDataBase.sim_run_input()SimDataBase.sim_run_input_fixup()SimDataBase.sim_run_input_path()SimDataBase.sim_run_input_to_run_dir()SimDataBase.sim_type()SimDataBase.support_files_to_run_dir()SimDataBase.update_model_defaults()SimDataBase.want_browser_frame_cache()SimDataBase.watchpoint_id()
audit_proprietary_lib_files()get_class()parse_frame_id()resource_path()template_globals()- Submodules
- sirepo.sim_data.activait module
- sirepo.sim_data.adm module
- sirepo.sim_data.canvas module
- sirepo.sim_data.controls module
- sirepo.sim_data.cortex module
- sirepo.sim_data.elegant module
- sirepo.sim_data.epicsllrf module
- sirepo.sim_data.flash module
SimDataSimData.COMPILE_LOGSimData.FLASH_PAR_FILESimData.SETUP_LOGSimData.SETUP_PARAMS_SCHEMA_FILESimData.fixup_old_data()SimData.flash_app_archive_basename()SimData.flash_app_lib_basename()SimData.flash_exe_basename()SimData.flash_problem_files_archive_basename()SimData.flash_problem_files_archive_hash()SimData.flash_setup_command()SimData.proprietary_code_lib_file_basenames()SimData.proprietary_code_tarball()SimData.sim_files_to_run_dir()
- sirepo.sim_data.genesis module
- sirepo.sim_data.hellweg module
- sirepo.sim_data.impactt module
- sirepo.sim_data.impactx module
- sirepo.sim_data.jspec module
- sirepo.sim_data.jupyterhublogin module
- sirepo.sim_data.lattice module
- sirepo.sim_data.madx module
- sirepo.sim_data.myapp module
- sirepo.sim_data.omega module
- sirepo.sim_data.opal module
- sirepo.sim_data.openmc module
- sirepo.sim_data.radia module
- sirepo.sim_data.raydata module
- sirepo.sim_data.shadow module
- sirepo.sim_data.silas module
- sirepo.sim_data.srw module
SimDataSimData.ANALYSIS_ONLY_FIELDSSimData.EXPORT_RSOPTSimData.ML_OUTPUTSimData.ML_REPORTSimData.SRW_FILE_TYPE_EXTENSIONSSimData.SRW_RUN_ALL_MODELSimData.does_api_reply_with_file()SimData.fixup_old_data()SimData.is_for_ml()SimData.is_for_rsopt()SimData.is_run_mpi()SimData.lib_file_name_with_type()SimData.lib_file_name_without_type()SimData.lib_file_names_for_type()SimData.sim_type()SimData.srw_compute_crystal_grazing_angle()SimData.srw_find_closest_angle()SimData.srw_format_float()SimData.srw_is_arbitrary_source()SimData.srw_is_background_report()SimData.srw_is_beamline_report()SimData.srw_is_dipole_source()SimData.srw_is_gaussian_source()SimData.srw_is_idealized_undulator()SimData.srw_is_tabulated_undulator_source()SimData.srw_is_tabulated_undulator_with_magnetic_file()SimData.srw_is_undulator_source()SimData.srw_is_user_defined_model()SimData.srw_is_valid_file()SimData.srw_is_valid_file_type()SimData.srw_lib_file_paths_for_type()SimData.srw_uses_tabulated_zipfile()SimData.want_browser_frame_cache()
- sirepo.sim_data.warppba module
- sirepo.sim_data.warpvnd module
- sirepo.sim_data.zgoubi module
- sirepo.sim_oauth package
- sirepo.template package
assert_sim_type()import_module()is_sim_type()run_epilogue()- Submodules
- sirepo.template.activait module
- sirepo.template.canvas module
- sirepo.template.code_variable module
CodeVarCodeVar.canonicalize()CodeVar.compute_cache()CodeVar.eval_var()CodeVar.eval_var_with_assert()CodeVar.generate_variables()CodeVar.get_expr_dependencies()CodeVar.infix_to_postfix()CodeVar.is_var_value()CodeVar.recompute_cache()CodeVar.stateful_compute_recompute_rpn_cache_values()CodeVar.stateful_compute_rpn_value()CodeVar.stateful_compute_validate_rpn_delete()CodeVar.validate_var_delete()
CodeVarDeleteIteratorCodeVarIteratorPurePythonEval
- sirepo.template.controls module
- sirepo.template.cortex module
- sirepo.template.elegant module
- sirepo.template.elegant_command_importer module
- sirepo.template.elegant_command_parser module
- sirepo.template.elegant_common module
- sirepo.template.elegant_lattice_importer module
- sirepo.template.elegant_lattice_parser module
- sirepo.template.epicsllrf module
- sirepo.template.flash module
- sirepo.template.flash_parser module
- sirepo.template.flash_views module
- sirepo.template.genesis module
- sirepo.template.hdf5_util module
- sirepo.template.hellweg module
- sirepo.template.hellweg_dump_reader module
- sirepo.template.impactt module
- sirepo.template.impactt_parser module
- sirepo.template.impactx module
- sirepo.template.jspec module
- sirepo.template.lattice module
ElementIteratorInputFileIteratorLatticeIteratorLatticeParserLatticeUtilLatticeUtil.explode_beamline()LatticeUtil.file_id()LatticeUtil.file_id_from_output_model_name()LatticeUtil.find_first_command()LatticeUtil.fixup_output_files()LatticeUtil.get_item()LatticeUtil.get_lattice_id_from_file_id()LatticeUtil.has_command()LatticeUtil.is_beamline()LatticeUtil.is_command()LatticeUtil.iterate_models()LatticeUtil.max_id()LatticeUtil.model_name_for_data()LatticeUtil.output_model_name()LatticeUtil.render_lattice()LatticeUtil.render_lattice_and_beamline()LatticeUtil.select_beamline()LatticeUtil.sort_elements_and_beamlines()LatticeUtil.type_for_data()
ModelIteratorUpdateIterator
- sirepo.template.line_parser module
LineParserLineParser.assert_char()LineParser.assert_end_of_line()LineParser.get_index()LineParser.has_char()LineParser.ignore_whitespace()LineParser.increment_line_number()LineParser.next_char()LineParser.next_id()LineParser.parse_quoted_value()LineParser.parse_value()LineParser.peek_char()LineParser.raise_error()LineParser.read_until()LineParser.reset_index()LineParser.set_line()
- sirepo.template.madx module
- sirepo.template.madx_converter module
- sirepo.template.madx_parser module
- sirepo.template.myapp module
- sirepo.template.omega module
- sirepo.template.opal module
- sirepo.template.opal_parser module
- sirepo.template.openmc module
- sirepo.template.openmc_util module
- sirepo.template.particle_beam module
- sirepo.template.radia module
- sirepo.template.radia_util module
- sirepo.template.raydata module
- sirepo.template.sdds_util module
- sirepo.template.shadow module
- sirepo.template.silas module
- sirepo.template.srw module
- sirepo.template.srw_common module
- sirepo.template.srw_debug module
- sirepo.template.srw_fixup module
- sirepo.template.srw_importer module
- sirepo.template.srw_shadow module
- sirepo.template.srwl_uti_brightness module
- sirepo.template.template_common module
INPUT_BASE_NAMEJobCmdFileLogParserModelUnitsNUMERIC_RENamelistParserNoH5PathErrorOUTPUT_BASE_NAMEPARAMETERS_PYTHON_FILEParticleEnergyRUN_LOGanalysis_job_dispatch()compute_field_range()compute_plot_color_and_range()enum_text()exec_parameters()exec_parameters_with_mpi()file_extension_ok()flatten_data()generate_parameters_file()get_exec_parameters_cmd()h5_to_dict()heatmap()histogram_bins()jinja_filename()model_from_frame_args()parameter_plot()parse_enums()parse_mpi_log()read_dict_from_h5()read_last_csv_line()read_sequential_result()render_jinja()sim_frame()sim_frame_dispatch()stateful_compute_dispatch()stateless_compute_dispatch()subprocess_output()text_data_file()validate_model()validate_models()write_dict_to_h5()write_sequential_result()
- sirepo.template.transfer_mat_bl module
- sirepo.template.warppba module
- sirepo.template.warpvnd module
- sirepo.template.zgoubi module
- sirepo.template.zgoubi_importer module
- sirepo.template.zgoubi_parser module
Submodules¶
sirepo.agent_supervisor_api module¶
Utilities for agent to supervisor api requests
For example, sim_db_file and global_resources.
- copyright:
Copyright (c) 2023 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.agent_supervisor_api.ReqBase(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]¶
Bases:
AuthHeaderRequestHandler- write_error(status_code, *args, **kwargs)[source]¶
Override to implement custom error pages.
write_errormay call write, render, set_header, etc to produce output as usual.If this error was caused by an uncaught exception (including HTTPError), an
exc_infotriple will be available askwargs["exc_info"]. Note that this exception may not be the “current” exception for purposes of methods likesys.exc_info()ortraceback.format_exc.
sirepo.api_auth module¶
authentication and authorization routines
- copyright:
Copyright (c) 2018 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.api_perm module¶
decorators for API permissions and the permissions themselves
- copyright:
Copyright (c) 2018 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.api_perm.APIPerm(*values)[source]¶
Bases:
FlagAn enumeration.
- ALLOW_COOKIELESS_REQUIRE_USER = 1¶
A user is required but there might not be a cookie yet
- ALLOW_COOKIELESS_SET_USER = 2¶
cookie set_user can be called even if a cookie wasn’t received
- ALLOW_SIM_TYPELESS_REQUIRE_EMAIL_USER = 8¶
a logged in email user is required but they don’t have to have a role for the sim type
- ALLOW_VISITOR = 4¶
anybody can view this page, even without cookies
- INTERNAL_TEST = 256¶
only usable on internal test systems
- REQUIRE_ADM = 16¶
only users with role adm
- REQUIRE_AUTH_BASIC = 32¶
use basic auth authentication (only)
- REQUIRE_COOKIE_SENTINEL = 64¶
a cookie has to have been returned, which might contain a user
- REQUIRE_PLAN = 512¶
a user with an active plan (any type) is required
- REQUIRE_PREMIUM = 1024¶
a user with a premium plan is required
- REQUIRE_USER = 128¶
a user will be created if necessary and auth may be necessary
- sirepo.api_perm.ATTR = 'api_perm'¶
decorator sets this attribute with an APIPerm
- sirepo.api_perm.SIM_TYPELESS_PERMS = {<APIPerm.ALLOW_COOKIELESS_SET_USER: 2>, <APIPerm.ALLOW_SIM_TYPELESS_REQUIRE_EMAIL_USER: 8>, <APIPerm.ALLOW_VISITOR: 4>, <APIPerm.REQUIRE_COOKIE_SENTINEL: 64>}¶
A user can access APIs decorated with these permissions even if they don’t have the role
- sirepo.api_perm.allow_cookieless_require_user(func)¶
- sirepo.api_perm.allow_cookieless_set_user(func)¶
- sirepo.api_perm.allow_sim_typeless_require_email_user(func)¶
- sirepo.api_perm.allow_visitor(func)¶
- sirepo.api_perm.internal_test(func)¶
- sirepo.api_perm.require_adm(func)¶
- sirepo.api_perm.require_auth_basic(func)¶
- sirepo.api_perm.require_cookie_sentinel(func)¶
- sirepo.api_perm.require_plan(func)¶
- sirepo.api_perm.require_user(func)¶
sirepo.auth_api module¶
apis for auth
- copyright:
Copyright (c) 2022 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.auth_role module¶
User roles
- copyright:
Copyright (c) 2021 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.auth_role.ModerationStatus(name, value=None, doc=None)[source]¶
Bases:
NamedConstantStates used by auth_role_moderation and UserRoleModeration
- APPROVE = <ModerationStatus.APPROVE: 'approve'>¶
- CLARIFY = <ModerationStatus.CLARIFY: 'clarify'>¶
- DENY = <ModerationStatus.DENY: 'deny'>¶
- PENDING = <ModerationStatus.PENDING: 'pending'>¶
- VALID_SET = frozenset({'approve', 'clarify', 'deny', 'pending'})¶
sirepo.auth_role_moderation module¶
sirepo.const module¶
Constant values
- copyright:
Copyright (c) 2021 RadiaSoft LLC. All Rights Reserved.
- license:
- sirepo.const.DEV_SRC_RADIASOFT_DIR = '~/src/radiasoft/'¶
hardwired root of development src tree; Not a py.path, because must defer tilde evaluation
- sirepo.const.LIB_DIR = 'lib'¶
where template resources and template non-sim user files live
- sirepo.const.SCHEMA_COMMON = {'websocketMsg': {'kind': {'asyncMsg': 4, 'httpReply': 2, 'httpRequest': 1, 'srException': 3}, 'method': {'setCookies': 'setCookies'}, 'version': 1}}¶
These values will be injected into simulation_db.SCHEMA_COMMON
- sirepo.const.SIM_DATA_BASENAME = 'sirepo-data.json'¶
Simulation file name saved both in sim db and run directory
- sirepo.const.SIM_RUN_INPUT_BASENAME = 'in.json'¶
Simulation file name saved both in sim db and run directory
sirepo.cron module¶
periodic callbacks
- copyright:
Copyright (c) 2025 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.cron.CronTask(period, coro_func, params)[source]¶
Bases:
objectCreates a task that runs a coroutine function periodically
coro_funcis called at startup and then periodically.coro_funcmust yield_to_event_loop to release processorFor global tasks, not associated with quest.
- Parameters:
- classmethod init_class(loop)[source]¶
Initialized by service
If
loopis None, then CronTasks do nothing (multi-server case).- Parameters:
loop (asyncio.EventLoop) – event loop or None
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:
- Returns:
- the resulted dictionary with:
lamda (float): wavelength [nm]. bragg_angle (float): Bragg angle [rad]. bragg_angle_deg (float): Bragg angle [deg].
- Return type:
- sirepo.crystal.get_crystal_parameters(material, energy_eV, h, k, l)[source]¶
Obtain parameters for the specified crystal and energy.
- Parameters:
- 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:
sirepo.csv module¶
wrappers to Python csv
- copyright:
Copyright (c) 2024 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.db_upgrade module¶
sirepo.events module¶
Reigster callbacks for events and call callbacks when events are emitted.
Using events allows disparate areas of the code base to perform some task on an event without muddling the code that triggered the event. In addition events can be registered by configuration. This allows areas of the code to register/emit events when they are configured on and doesn’t require if statements throughout the code.
For example, when a user logs out the AUTH_LOGOUT event is emitted. Other areas of the code can register a callback for this event (ex to clear jupyterhub cookies so the user is logged out of jupyterhub too).
The events: - ‘auth_logout’ emitted when a user logs out, before the cookie is cleared.
kwargs contains uid.
‘end_api_call’ emitted at the end of call_api. kwargs contains response object.
- copyright:
Copyright (c) 2020 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.exporter module¶
sirepo.feature_config module¶
List of features available
To add a code that is not in the default list:
export SIREPO_FEATURE_CONFIG_SIM_TYPES=raydata:DEFAULT
- copyright:
Copyright (c) 2016-2025 RadiaSoft LLC. All Rights Reserved.
- license:
- sirepo.feature_config.auth_controlled_sim_types()[source]¶
All sim types that require granted authentication to access
- Returns:
enabled sim types that require role
- Return type:
- sirepo.feature_config.cfg()[source]¶
global configuration
- Returns:
configurated features
- Return type:
sirepo.file_lock module¶
file locking
- copyright:
Copyright (c) 2023 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.file_lock.AsyncFileLock(path, qcall)[source]¶
Bases:
_BaseLock a file for global mutex
- Parameters:
path (py.path.local) – base name for lock
qcall (sirepo.quest.API) – to ensure not re-entrant
sirepo.html module¶
html template
- copyright:
Copyright (c) 2020 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.http_request module¶
request input parsing
- copyright:
Copyright (c) 2018 RadiaSoft LLC. All Rights Reserved.
- license:
- sirepo.http_request.parse_post(qcall, kwargs)[source]¶
Parse a post augmented by inline args
Arguments are either bool or another object. If a bool and True, the value is parsed from req_data. If another object, the value is parsed as is, setting on req_data.
The names of the args are the keys of the return value.
- Parameters:
req_data (PKDict) – input values [body_as_dict]
type (object) – assert_sim_type
file_type (object) – sirepo.util.secure_filename
filename (object) – sirepo.util.secure_filename
folder (object) – parse_folder
id (object) – parse_sid
model (object) – parse_model
name (object) – parse_name
template (object) – sirepo.template.import_module
- Returns:
with arg names set to parsed values
- Return type:
PKDict
sirepo.http_util module¶
Support routines for http requests/responses
- copyright:
Copyright (c) 2024 RadiaSoft LLC. All Rights Reserved.
- license:
- sirepo.http_util.auth_header(token)[source]¶
Construct RFC6750 auth header compatible with requests.
- Parameters:
token (str) – Secret to be included in the header
- Returns
PKDict: auth header
sirepo.hundli_console module¶
Hundli: a dog height and weight simulation engine
This is not technically part of Sirepo. It demonstrates a arbitrary 3rd party code, which Sirepo calls as an independent program.
- copyright:
Copyright (c) 2018 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.importer module¶
sirepo.job module¶
Common functionality that is shared between the server, supervisor, and driver.
- copyright:
Copyright (c) 2019-2023 RadiaSoft LLC. All Rights Reserved.
- license:
- sirepo.job.ACTIVE_STATUSES = frozenset({'pending', 'running'})¶
Queued or running
- sirepo.job.AGENT_URI = '/job-agent-websocket'¶
path supervisor registers to receive messages from agent
- sirepo.job.CANCELED = 'canceled'¶
status values
- sirepo.job.CMD_COMPUTE = 'compute'¶
job_cmds
- sirepo.job.CPU_SLOT_OPS = frozenset({'analysis', 'run'})¶
Types of slots required by op types
- sirepo.job.DATA_FILE_ROOT = None¶
where user data files come in (job_supervisor)
- sirepo.job.DATA_FILE_URI = '/job-cmd-data-file'¶
path supervisor registers to receive requests from job_process for file PUTs
- sirepo.job.DEFAULT_IP = '127.0.0.1'¶
address where supervisor binds to
- sirepo.job.DEFAULT_PORT = 8001¶
port supervisor listens on
- sirepo.job.DEFAULT_SUPERVISOR_URI_DECL = ('http://127.0.0.1:8001', <class 'str'>, 'how to reach supervisor')¶
_cfg declaration for supervisor_uri for drivers
- sirepo.job.EXIT_STATUSES = frozenset({'canceled', 'completed', 'error', 'job_run_purged', 'missing'})¶
When the job is inactive
- sirepo.job.GLOBAL_RESOURCES_URI = '/global-resources'¶
path supervisor registers to receive requests from job_process for global resources
- sirepo.job.JOB_CMD_STATE_SBATCH_RUN_STATUS_STOP = 'sbatch_run_status_stop'¶
For communication between job_agent and job_cmd
- sirepo.job.KINDS = frozenset({'parallel', 'sequential'})¶
categories of jobs
- sirepo.job.NERSC_QUEUE_MAX = {'cores': {'debug': 34816, 'premium': 56704, 'regular': 61824}, 'hours': {'debug': 0.5, 'premium': 48, 'regular': 48}}¶
Max values for each nersc queue
- sirepo.job.OPS_WITHOUT_SLOTS = frozenset({'alive', 'begin_session', 'cancel', 'error', 'kill', 'ok', 'run_status', 'sbatch_agent_ready', 'sbatch_login'})¶
Ops which don’t need slot allocations or supervisor does not send
- sirepo.job.OP_ALIVE = 'alive'¶
Agent indicates it is ready
- sirepo.job.QUASI_SID_RE = re.compile('^_1_')¶
Allow sids for different kinds of jobs (not simulations)
- sirepo.job.RUN_MODES = frozenset({'parallel', 'sbatch', 'sequential'})¶
valid jobRunMode values
- sirepo.job.SEQUENTIAL = 'sequential'¶
jobRunMode and kinds; should come from schema
- sirepo.job.SERVER_PING_URI = '/job-api-ping'¶
path supervisor registers to receive pings from server
- sirepo.job.SERVER_SRTIME_URI = '/job-api-srtime'¶
path supervisor registers to receive srtime adjustments from server
- sirepo.job.SERVER_URI = '/job-api-request'¶
path supervisor registers to receive requests from server
- sirepo.job.SIM_DB_FILE_URI = '/sim-db-file'¶
path supervisor registers to receive requests from job_process for simulation file GETs/PUTs
- sirepo.job.SLOT_OPS = frozenset({'analysis', 'io', 'run'})¶
All ops that have slots (see job_driver.DriverBase._slots_ready)
- sirepo.job.STATE_OK = 'ok'¶
state value (other states are implicit statuses)
- sirepo.job.STATUSES = frozenset({'canceled', 'completed', 'error', 'job_run_purged', 'missing', 'pending', 'running'})¶
Valid values for job status
- sirepo.job.SUPERVISOR_SRV_ROOT = None¶
how jobs request files (absolute)
- sirepo.job.SUPERVISOR_SRV_SUBDIR = 'supervisor-srv'¶
how jobs request files (relative to srdb.root)
- sirepo.job.agent_cmd_stdin_env(cmd, env, uid, cwd='.', source_bashrc='')[source]¶
Convert cmd with env to script and cmd
Uses tempfile so the file can be closed after the subprocess gets the handle. You have to close stdin after calling tornado.process.Subprocess, which calls subprocess.Popen inline, since it’ not
async.
- sirepo.job.join_jid(uid, sid, compute_model)[source]¶
A Job is a tuple of user, sid, and compute_model.
A jid is words and dashes.
- sirepo.job.sbatch_login_ok()[source]¶
Response for sbatchLogin API
- Returns:
success response
- Return type:
PKDict
sirepo.job_api module¶
sirepo.job_supervisor module¶
sirepo.jupyterhub module¶
sirepo.lib module¶
Public functions from sirepo
Use this to call sirepo from other packages or Python notebooks.
- copyright:
Copyright (c) 2020 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.lib.GenerateBase[source]¶
Bases:
objectCommon functionality between code specific Generate implementations.
- property util¶
- class sirepo.lib.Importer(sim_type, ignore_files=None, update_filenames=False)[source]¶
Bases:
objectImports a code’s native files into Sirepo representation
- Parameters:
- class sirepo.lib.LibAdapterBase(ignore_files=None, update_filenames=False)[source]¶
Bases:
objectCommon functionality between code specific LibAdapter implementations.
sirepo.modules module¶
initialize modules based on mode
- copyright:
Copyright (c) 2022 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.mpi module¶
Run Python processes in background
- copyright:
Copyright (c) 2016 RadiaSoft LLC. All Rights Reserved.
- license:
- sirepo.mpi.restrict_op_to_first_rank(op)[source]¶
If the process has rank FIRST_RANK, call a function. Otherwise do nothing.
Use this to call a function that will cause conflicts if called by multiple processes, such as writing results to a file
- Parameters:
op (function) – function to call
- Returns:
result of op
- Return type:
- sirepo.mpi.restrict_ops_to_first_node(ops)[source]¶
Run ops in parallel on available cores on the first node
This functions uses multiprocessing to run ops. If run under MPI, will run instantiate the multiprocessing.Pool in the first rank only, and the other MPI ranks (processes) will remain idle until all ops have been run.
Note that processes originate from the first rank MPI process so they share the first rank’s memory up until multiprocessing spawns each op.
- Parameters:
ops (iterable) – produces callables that will be run in parallel
sirepo.nersc module¶
Methods related to running on NERSC
- copyright:
Copyright (c) 2023 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.numpy module¶
Wrappers for numpy
- copyright:
Copyright (c) 2022 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.oauth module¶
oauth for authentication and role moderation
- copyright:
Copyright (c) 2022 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.payments module¶
Payment handling with Stripe
- copyright:
Copyright (c) 2025 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.quest module¶
Requests hold context for API calls
- copyright:
Copyright (c) 2019-2022 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.quest.API(in_pkcli=False)[source]¶
Bases:
APIHolds request context for all API calls.
- async call_api(name, kwargs=None, body=None)[source]¶
Calls uri_router.call_api, which calls the API with permission checks.
- Parameters:
name (object) – api name (without api_ prefix)
kwargs (PKDict) – to be passed to API [None]
body (PKDict) – will be returned self.body_as_dict [None]
- Returns:
result
- Return type:
Reply
- parent_set(parent)[source]¶
Links parent qcall to self and copies Attrs
- Parameters:
parent (API) – qcall to link as parent
- reply_redirect_for_local_route(sim_type=None, route=None, params=None, query=None, **kwargs)[source]¶
- class sirepo.quest.Attr(qcall, init_quest_for_child=False, **kwargs)[source]¶
Bases:
PKDict- detach_from_quest()[source]¶
Useful only for _SReply
Detaches from the quest so won’t be destroyed.
- Returns:
object
- Return type:
self
sirepo.reply module¶
Reply hold the response to API calls.
Replies are independent of the web platform (tornado http or websocket). They are converted to the native format by the platform dispatcher at the time. Internal call_api returns an _SReply object.
- copyright:
Copyright (c) 2023 RadiaSoft LLC. All Rights Reserved.
- license:
- sirepo.reply.CACHE_MAX_AGE = 43200¶
default Max-Age header
- sirepo.reply.SR_EXCEPTION_STATE = 'srException'¶
data.state for srException
sirepo.request module¶
Requests hold context for API calls
- copyright:
Copyright (c) 2022 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.resource module¶
Functions for accessing resource files
- copyright:
Copyright (c) 2021 RadiaSoft LLC. All Rights Reserved.
- license:
- sirepo.resource.file_path(*paths)[source]¶
Get absolute path to a resource file
- Parameters:
paths (str) – Names of paths to get to resource file
- Returns:
absolute path to resource file
- Return type:
py.path
- sirepo.resource.glob_paths(*paths)[source]¶
Get matching paths
- Parameters:
paths (str) – Path components of file
- Returns:
paths that match pattern
- Return type:
[py.path]
- sirepo.resource.render_jinja(*paths, target_dir=None, j2_ctx=None)[source]¶
Render a resource template file with Jinja into target_dir.
- Parameters:
paths (str) – Path components of resource file without pykern.pkjinja.RESOURCE_SUFFIX
target_dir (py.path) – target directory for rendered file
j2_ctx (PKDict) – parameters to jinja file
- Returns:
output path which is target_dir.join(paths[-1])
- Return type:
py.path
- sirepo.resource.root_modules()[source]¶
Get all root modules in package_path
- Returns:
root modules
- Return type:
[module]
- sirepo.resource.static(*paths)[source]¶
Absolute or relative path to resource static file
- Parameters:
paths (str) – Path components of file
- Returns:
path to file
- Return type:
py.path
- sirepo.resource.static_files()[source]¶
Generate all, non-overlapping, non-dot static files
- Yields:
(str, py.path) – relative path (including static) and absolute paths
sirepo.server module¶
sirepo.sim_db_file module¶
Operating on simulation db files via the job agent
- copyright:
Copyright (c) 2020 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.sim_db_file.SimDbClient(sim_data)[source]¶
Bases:
objectClient to be used from the job agent.
An instance is created and is accessed via SimData.sim_db_client.
- LIB_DIR = 'lib'¶
- delete_glob(lib_sid_uri, path_prefix, sim_type=None)[source]¶
deletes files that begin with path_prefix
- class sirepo.sim_db_file.SimDbServer(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]¶
Bases:
ReqBase
- class sirepo.sim_db_file.SimDbUri(sim_type, slu, basename)[source]¶
Bases:
strIdentifies the relative path to a file in the simulation db.
The value is a URI comprised of parts: sim_type, sim_id or LIB_DIR and basename.
If slu is a SimDbUri, basename must match it or be None. sim_type must match the SimDbUri.
sirepo.sim_run module¶
sirepo.simulation_db module¶
sirepo.sirepo_console module¶
Front-end command line for sirepo.
See pykern.pkcli for how this module is used.
- copyright:
Copyright (c) 2015-2024 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.smtp module¶
SMTP connection to send emails
- copyright:
Copyright (c) 2018-2024 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.spa_session module¶
Manage user sessions
- copyright:
Copyright (c) 2022 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.srdb module¶
db configuration
- copyright:
Copyright (c) 2019 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.srschema module¶
Simulation schema
- copyright:
Copyright (c) 2018 RadiaSoft LLC. All Rights Reserved.
- license:
- sirepo.srschema.validate(schema)[source]¶
Validate the schema
- Validations performed:
Values of default data (if any) Existence of dynamic modules Enums keyed by string value Model names containing special characters Method name for API calls with them are valid python function names and not too long
- Parameters:
schema (PKDict) – app schema
sirepo.srtime module¶
time functions (artificial time)
- copyright:
Copyright (c) 2019 RadiaSoft LLC. All Rights Reserved.
- license:
- sirepo.srtime.EPOCH = datetime.datetime(1970, 1, 1, 0, 0)¶
POSIX epoch as object
- sirepo.srtime.adjust_time(days)[source]¶
Shift the system time by days
- Parameters:
days (str) – must be integer. If None or 0, clear the adjustment.
- sirepo.srtime.to_timestamp(dt)[source]¶
Convert datetime into float seconds from epoch
- Parameters:
dt (datetime) – datetime object
- Returns:
seconds since epoch
- Return type:
- sirepo.srtime.utc_now()[source]¶
Adjusted UTC time as object
- Returns:
adjusted pykern.pkcompat.utcnow
- Return type:
sirepo.srunit module¶
Support for unit tests
- copyright:
Copyright (c) 2016 RadiaSoft LLC. All Rights Reserved.
- license:
- sirepo.srunit.CONFTEST_DEFAULT_CODES = None¶
set by conftest.py
- exception sirepo.srunit.JobAgentError[source]¶
Bases:
RuntimeError
- sirepo.srunit.MYAPP = 'myapp'¶
Default “app”
- exception sirepo.srunit.ServerRequestError[source]¶
Bases:
RuntimeError
- sirepo.srunit.http_client(env=None, sim_types=None, job_run_mode=None, empty_work_dir=True, port=None)[source]¶
Create an http_client that talks to server
sirepo.srunit_api module¶
Support for sirepo.srunit tests
- copyright:
Copyright (c) 2023 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.srunit_servers module¶
start servers for unit tests
- copyright:
Copyright (c) 2024 RadiaSoft LLC. All Rights Reserved.
- license:
sirepo.status module¶
sirepo.tornado module¶
Wrappers for Tornado
- copyright:
Copyright (c) 2020 RadiaSoft LLC. All Rights Reserved.
- license:
- class sirepo.tornado.AuthHeaderRequestHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]¶
Bases:
RequestHandler
- class sirepo.tornado.Event[source]¶
Bases:
EventEvent with ordered waiters.
When the event is set the waiters are awoken in a FIFO order.
sirepo.uri module¶
uri formatting
- copyright:
Copyright (c) 2019 RadiaSoft LLC. All Rights Reserved.
- license:
- sirepo.uri.PARAM_RE = '([\\?\\*]?)<{}>'¶
route parsing
- sirepo.uri.PATH_INFO_CHAR = '*'¶
optional parameter that consumes rest of parameters
- sirepo.uri.is_sr_exception_only(sim_type, route_name)[source]¶
local route has srExceptionOnly param
- sirepo.uri.local_route(sim_type, route_name=None, params=None, query=None)[source]¶
Generate uri for local route with params
sirepo.uri_router module¶
Handles dispatching of uris to server.api_* functions
- copyright:
Copyright (c) 2017 RadiaSoft LLC. All Rights Reserved.
- license:
- async sirepo.uri_router.call_api(qcall, name, kwargs=None, body=None)[source]¶
Should not be called outside of Base.call_api(). Use self.call_api() to call API.
Call another API with permission checks.
- sirepo.uri_router.init_module(want_apis, **imports)[source]¶
Convert route map to dispatchable callables
Initializes _uri_to_route
- sirepo.uri_router.register_api_module(module)[source]¶
Add caller_module to the list of modules which implements apis.
The module must have methods: api_XXX which do not collide with other apis. It may also have init_apis(), which will be called unless it is already registered.
- Parameters:
module (module or str) – name of module or module
sirepo.util module¶
Support routines and classes, mostly around errors and I/O.
- copyright:
Copyright (c) 2018 RadiaSoft LLC. All Rights Reserved.
- license:
- exception sirepo.util.ContentTooLarge(*args, **kwargs)[source]¶
Bases:
ReplyExcThe content requested by the user was too large (ex large data file)
- exception sirepo.util.Error(error, *args, **kwargs)[source]¶
Bases:
ReplyExcRaised to send an error response
- Parameters:
error_msg (str) – just the error to output to user
- exception sirepo.util.InvalidEmail(*args, **kwargs)[source]¶
Bases:
ReplyExcEmail user is trying to register with is malformed or domain is on deny list.
- exception sirepo.util.OKReplyExc(*args, **kwargs)[source]¶
Bases:
ReplyExcWhen a ReplyExc exception is a successful response
- exception sirepo.util.PlanExpired(*args, **kwargs)[source]¶
Bases:
ReplyExcAPI requires and active plan
- exception sirepo.util.Redirect(uri, *args, **kwargs)[source]¶
Bases:
OKReplyExcRaised to redirect
- exception sirepo.util.ReplyExc(*args, **kwargs)[source]¶
Bases:
ExceptionRaised to end the request.
- exception sirepo.util.SPathNotFound(sim_type, uid, sid, *args, **kwargs)[source]¶
Bases:
NotFoundRaised by simulation_db
- exception sirepo.util.SRException(route_name, params, *args, **kwargs)[source]¶
Bases:
ReplyExcRaised to communicate a local redirect and log info
params may have
simulationType, which will be used for routeName rendering. Otherwise,sim_typeonqcallwill be used.
- exception sirepo.util.SReplyExc(sreply, *args, **kwargs)[source]¶
Bases:
OKReplyExcRaise with an SReply object
- sirepo.util.TOKEN_SIZE = 16¶
length of string returned by create_token
- sirepo.util.UNIQUE_KEY_CHARS_RE = '\\w+'¶
Matches anything generated by unique_key
- Type:
POSIT
- sirepo.util.UNIQUE_KEY_RE = re.compile('^\\w+$')¶
A standalone unique key
- exception sirepo.util.Unauthorized(*args, **kwargs)[source]¶
Bases:
ReplyExcRaised to generate 401 response
- exception sirepo.util.UserAlert(display_text, *args, **kwargs)[source]¶
Bases:
ReplyExcRaised to display a user error and log info
- exception sirepo.util.UserDirNotFound(user_dir, uid, *args, **kwargs)[source]¶
Bases:
NotFoundRaised by simulation_db
- Parameters:
user_dir (py.path) – directory not found
uid (str) – user
- exception sirepo.util.WWWAuthenticate(*args, **kwargs)[source]¶
Bases:
ReplyExcRaised to generate 401 response with WWWAuthenticate response
- sirepo.util.find_obj(arr, key, value)[source]¶
Return the first object in the array such that obj[key] == value
- sirepo.util.import_submodule(submodule, type_or_data)[source]¶
Import fully qualified module that contains submodule for sim type
sirepo.feature_config.package_path will be searched for a match.
- sirepo.util.json_dump(obj, path=None, pretty=False, **kwargs)[source]¶
Formats as json as string, and writing atomically to disk
- sirepo.util.json_path(path, run_dir=None)[source]¶
Append sirepo.const.JSON_SUFFIX if necessary and convert to str
- Parameters:
path (py.path or str) – to convert
run_dir (py.path) – which directory to join (only if path is str)
- Returns:
path.json
- Return type:
py.path
- sirepo.util.numpy_to_py(obj)[source]¶
Convert numpy objects to Python objects
Use to avoid repr conversions.
- sirepo.util.plan_role_expiration(role)[source]¶
Get expiration for an (asserted) plan
- Parameters:
role (str) – plan to change to
- Returns:
new expiration
- Return type:
datetime
- sirepo.util.random_base62(length=32, prefix=None)[source]¶
Returns a safe string of sufficient length to be a nonce
- sirepo.util.read_zip(path_or_bytes)[source]¶
Read the contents of a zip archive.
Protects against malicious filenames (ex ../../filename)
- sirepo.util.sanitize_string(string)[source]¶
Remove special characters from string
This results in a string the is a valid python identifier. This string can also be used as a css id because valid python identifiers are also valid css ids.