API
API#
- class run_logger.main.NewParams(config_params: Optional[dict], sweep_params: Optional[dict], load_params: Optional[dict])#
- run_logger.main.create_run(logger=None, config=None, charts=None, metadata=None, sweep_id=None, load_id=None)#
Creates a new run. It registers the run in the database (using
HasuraLogger.create_run
) and returns aNewParams
object, which provides parameters from three sources:a config file (if provided)
a sweep (if the run is enrolled in a sweep)
the parameters from an existing run (if
load_id
is provided)
- Parameters
logger – A HasuraLogger object. If
None
, the run is not registered in the database.config – A path to a
yaml
config file.charts – A list of charts to be added to the database, associated with this run.
sweep_id – The ID of the sweep in which the run is enrolled (if any).
load_id – The ID of an existing run whose parameters you want to access.
- run_logger.main.get_load_params(load_id, logger)#
Returns the parameters of an existing run.
- Parameters
load_id – The ID of an existing run whose parameters you want to access.
logger – A HasuraLogger object associated with the database where the run is stored.
- run_logger.main.initialize(graphql_endpoint=None, config=None, charts=None, metadata=None, name=None, sweep_id=None, load_id=None, **params)#
The main function to initialize a run. It creates a new run and returns the parameters and a HasuraLogger object, which is a handle for accessing the database.
- Parameters
graphql_endpoint – The endpoint of the Hasura GraphQL API, e.g.
https://server.university.edu:1200/v1/graphql
. If this value isNone
, the run will not be logged in the database.config – An optional path to a
yaml
config file file containing parameters. See the section on Config files for more details.charts – A list of Vega or Vega-Lite graphical specifications, to be displayed by run-visualizer.
metadata – Any JSON-serializable object to be stored in the database.
name – An optional name to be given to the run.
sweep_id – An optional sweep ID, to enroll this run in a sweep.
load_id – An optional run ID, to load parameters from an existing run.
params – Existing (usually default) parameters provided for the run (and updated by
update_params
).
- Returns
A tuple of parameters and a HasuraLogger object.
- run_logger.main.update_params(logger, new_params, name, **params)#
This is a convenience wrapper
HasuraLogger.update_metadata
Updates the existing parameters of a run (params
) with new parameters using the Hasura _append operator.Parameters are updated with the following precedence: 1. Load parameters (parameters corresponding to an existing run, specified by
load_id
) if any. 2. sweep parameters (parameters issued by a sweep, specified bysweep_id
) if any. 3. config parameters (parameters specified in a config file, specified byconfig
) if any.That is, sweep parameters will overwrite config parameters and load parameters will overwrite sweep parameters.
Note that this function does mutate the metadata stored in the database.
- Parameters
logger – A HasuraLogger object associated with the database containing the run whose parameters need to be updated.
new_params – The new parameters.
name – A name to be given to the run.
params – Existing parameters (e.g. command line defaults).
- Returns
Updated parameters.