openquake.server package#
Subpackages#
- openquake.server.db package
- openquake.server.db.actions module
Listadd_tag_to_job()calc_info()check_outdated()create_job()create_outputs()create_tag()db_version()del_calc()delete_tag()delete_uncompleted_calculations()engine_version()find()finish()get_calc_ids()get_calcs()get_checksum_from_job()get_executing_jobs()get_job()get_job_from_checksum()get_job_id_from_checksum()get_job_stats()get_jobs()get_jobs_by_date()get_log()get_log_size()get_log_slice()get_longest_jobs()get_output()get_outputs()get_preferred_job_for_tag()get_result()get_results()get_running_jobs()get_traceback()get_uncompleted_jobs()get_weight()has_job_table()import_job()keep()list_calculations()list_outputs()list_tags()log()remove_tag_from_job()reset_is_running()set_preferred_job_for_tag()set_status()share_job()unset_preferred_job_for_tag()update_job()update_job_checksum()update_parent_child()upgrade_db()what_if_I_upgrade()
- openquake.server.db.upgrade_manager module
DuplicatedVersionUpgradeManagerUpgradeManager.ENGINE_URLUpgradeManager.UPGRADESUpgradeManager.check_versions()UpgradeManager.extract_upgrade_scripts()UpgradeManager.get_db_versions()UpgradeManager.init()UpgradeManager.install_versioning()UpgradeManager.instance()UpgradeManager.parse_script_name()UpgradeManager.read_scripts()UpgradeManager.upgrade()
VersionTooSmallVersioningNotInstalledWrappedConnectionapply_sql_script()check_script()db_version()upgrade_db()what_if_I_upgrade()
- Module contents
- openquake.server.db.actions module
- openquake.server.v1 package
Submodules#
openquake.server.manage module#
openquake.server.middleware module#
- class openquake.server.middleware.LoginRequiredMiddleware(get_response)[source]#
Bases:
objectMiddleware that requires a user to be authenticated to view any page other than LOGIN_URL. Exemptions to this requirement can be specified in settings via a list of regular expressions in LOGIN_EXEMPT_URLS.
Requires authentication middleware and template context processors to be loaded. You’ll get an error if they aren’t.
openquake.server.settings module#
openquake.server.urls module#
openquake.server.utils module#
- openquake.server.utils.check_webserver_running(url='http://localhost:8800', max_retries=30, warn=True)[source]#
Returns True if a given URL is responding within a given timeout.
- openquake.server.utils.get_acl_on(request)[source]#
Returns True if ACL should be honorated, returns otherwise False.
- openquake.server.utils.get_username(request)[source]#
Returns the users from request if authentication is enabled, otherwise returns the default user (from settings, or as reported by the OS).
- openquake.server.utils.get_valid_users(request)[source]#
” Returns a list of users based on groups membership. Returns a list made of a single user when it is not member of any group.
- openquake.server.utils.is_superuser(request)[source]#
Without authentication (settings.LOCKDOW is false) every user is considered a superuser, otherwise look at the attribute request.user.is_superuser.
openquake.server.views module#
- openquake.server.views.aelo_callback(job_id, job_owner_email, outputs_uri, inputs, exc=None, warnings=None, email_file_path=None)[source]#
- openquake.server.views.build_impact_resources(request, calc_id, dstore)[source]#
Describe impact resources and their presentation URLs.
- openquake.server.views.determine_precision(weights)[source]#
Determine the minimum decimal places needed to represent the weights accurately
- openquake.server.views.get_impact_rupture_data(post, user, rupture_path)[source]#
Validate a rupture and build the data needed by the IMPACT UI.
- openquake.server.views.group_keys_by_value(d)[source]#
Groups keys from the input dictionary by their shared values. If a value is shared by multiple keys, those keys are grouped into a tuple. Otherwise, the key is kept as-is.
- Parameters:
d – a dictionary with hashable keys and values
- Returns:
a dictionary where keys are either individual keys or tuples of keys that shared the same value, and values are the original values
- Example:
>>> group_keys_by_value({0: 'a', 1: 'b', 2: 'a'}) {(0, 2): 'a', 1: 'b'}
- openquake.server.views.impact_callback(job_id, params, job_owner_email, outputs_uri, exc=None, warnings=None, email_file_path=None)[source]#
- openquake.server.views.save_pik(job, dirname)[source]#
Save a LogContext object in pickled format; returns the path to it
- openquake.server.views.stream_response(fname, content_type, exportname='')[source]#
Stream a file stored in a temporary directory via Django
openquake.server.internal_api module#
Internal API of the WebUI, served by Django under the /v0 and /v1
paths of the server.
The functions without the v0_/v1_ prefix implement the endpoints:
they are called in-process by openquake.server.views and they raise
ApiError on failure. The decorated functions are the HTTP views,
which check the internal API key and turn the outcome into a response.
- exception openquake.server.internal_api.ApiError(status, detail=None, content=None)[source]#
Bases:
ExceptionError returned to the caller with the given HTTP status.
- class openquake.server.internal_api.ExportResponse(fname, **kwargs)[source]#
Bases:
FileResponseStream an exported file and remove its directory once closed.
- openquake.server.internal_api.calc_info(calc_id)[source]#
Return the information about a calculation.
- openquake.server.internal_api.calc_list_count(params, valid_users, acl_on)[source]#
Count the calculations matching the filters of the list view.
- openquake.server.internal_api.calc_log(calc_id, start, stop)[source]#
Return a slice of the log of a calculation.
- openquake.server.internal_api.calc_log_size(calc_id)[source]#
Return the number of log lines of a calculation.
- openquake.server.internal_api.calc_remove(calc_id, username)[source]#
Remove a calculation on behalf of its owner.
- openquake.server.internal_api.calc_result(result_id, export_type=None)[source]#
Export a result in the requested format, as a downloadable file.
- openquake.server.internal_api.calc_run(form)[source]#
Submit a calculation, using the archive in the form if present.
- openquake.server.internal_api.calc_traceback(calc_id)[source]#
Return the traceback of a calculation.
- openquake.server.internal_api.db_action(action, payload)[source]#
Execute an allowlisted database action.
- openquake.server.internal_api.get_impact_resource_data(dstore)[source]#
Return available IMPACT resources without presentation URLs.
- openquake.server.internal_api.get_uploaded_file_path(files, filename)[source]#
Copy an uploaded file to a temporary path and return its location.
- openquake.server.internal_api.has_api_key(request)[source]#
Return whether the request carries the internal API key.
- openquake.server.internal_api.impact_form_defaults()[source]#
Return the default values for the IMPACT form.
- openquake.server.internal_api.impact_get_rupture_data(form)[source]#
Build the rupture data of an IMPACT job from the given form.
- openquake.server.internal_api.impact_run(form)[source]#
Run an IMPACT calculation from the given form.
- openquake.server.internal_api.internal_view(*methods, auth=True)[source]#
Turn a function of the request into a Django view accepting only the given HTTP methods. The view is exempt from CSRF checks, since the callers are programs, and it requires the internal API key unless
authis false.
- openquake.server.internal_api.json_response(data, status=200)[source]#
Return a JSON response, converting dates and numpy scalars.
- openquake.server.internal_api.make_form(*sources)[source]#
Merge plain fields (dictionaries or QueryDicts) and uploaded files into a single MultiValueDict, the form accepted by the internal functions.
- openquake.server.internal_api.model_provenance(calc_id)[source]#
Return the model provenance of a calculation.
- openquake.server.internal_api.run(func, *args, **kwargs)[source]#
Call an internal API function and return its response. The errors raised as
ApiErroror asdbapi.NotFoundbecome JSON error responses, while a returned HTTP response is passed unchanged.
- openquake.server.internal_api.run_scenario_calc_from_ses_rupture(rup_id, form)[source]#
Run a PAPERS scenario calculation for an SES rupture.
- openquake.server.internal_api.v0_aelo_run(request)[source]#
Run an AELO calculation for an authenticated Django caller.
- openquake.server.internal_api.v0_calc_abort(request, calc_id)[source]#
Abort a running calculation for an authenticated caller.
- openquake.server.internal_api.v0_calc_log(request, calc_id, start, stop)[source]#
Return a calculation log slice.
- openquake.server.internal_api.v0_calc_log_size(request, calc_id)[source]#
Return the number of log lines for a calculation.
- openquake.server.internal_api.v0_calc_remove(request, calc_id)[source]#
Remove a calculation for an authenticated caller.
- openquake.server.internal_api.v0_calc_result(request, result_id)[source]#
Export a calculation result in the requested format.
- openquake.server.internal_api.v0_calc_run(request)[source]#
Submit a calculation for an authenticated Django caller.
- openquake.server.internal_api.v0_calc_traceback(request, calc_id)[source]#
Return the traceback for a calculation.
- openquake.server.internal_api.v0_db_action(request, action)[source]#
Execute an allowlisted database action.
- openquake.server.internal_api.v0_impact_get_rupture_data(request)[source]#
Build IMPACT rupture data for an authenticated Django caller.
- openquake.server.internal_api.v0_impact_run(request)[source]#
Run IMPACT for an authenticated Django caller.
- openquake.server.internal_api.v0_model_provenance(request, calc_id)[source]#
Return the model provenance of a calculation.
- openquake.server.internal_api.v0_run_scenario(request, rup_id)[source]#
Run a papers scenario calculation for an authenticated caller.
- openquake.server.internal_api.v0_validate_zip(request)[source]#
Validate an uploaded calculation archive.
- openquake.server.internal_api.v0_worker(request, action)[source]#
Run an authenticated worker-control action.
- openquake.server.internal_api.v1_aelo_site_classes(request)[source]#
Return the AELO site-class definitions.
- openquake.server.internal_api.v1_calc_info(request, calc_id)[source]#
Return the information about a calculation.
- openquake.server.internal_api.v1_calc_list_count(request)[source]#
Count the calculations matching the filters of the list view.
- openquake.server.internal_api.v1_impact_form_defaults(request)[source]#
Return the default values for the IMPACT form.
- openquake.server.internal_api.validate_job(job_file)[source]#
Validate a calculation input and return its JSON-compatible result.