DB Methods¶
Database methods
-
class
iceprod.server.dbmethods.CacheInfo¶ CacheInfo(hits, misses, maxsize, currsize)
Create new instance of CacheInfo(hits, misses, maxsize, currsize)
-
currsize¶ Alias for field number 3
-
hits¶ Alias for field number 0
-
maxsize¶ Alias for field number 2
-
misses¶ Alias for field number 1
-
-
iceprod.server.dbmethods.memcache(size=1024, ttl=None)[source]¶ Caching decorator.
Instrumented like
functools.lru_cache()with cache_clear() and cache_info().Parameters:
Authorization decorator.
Must be used on a member function of dbmethods in order to access the DB for authorization information.
- Non-decorator optional args:
- passkey (str): the passkey (for site, task, or user) cookie_id (str): the user_id supplied by a cookie site_id (str): the site id
Parameters:
-
iceprod.server.dbmethods.filtered_input(input_data)[source]¶ Filter input to sql in cases where we can’t use bindings. Just remove all ” ‘ ; : ? characters, since those won’t be needed in proper names
-
iceprod.server.dbmethods.dbmethod(func)¶
Authorization and security database methods
-
class
iceprod.server.dbmethods.auth.auth(parent)[source]¶ The authorization / security DB methods.
Takes a handle to a subclass of iceprod.server.modules.db.DBAPI as an argument.
-
auth_get_site_auth(*args, **kwargs)¶
-
auth_get_passkey(*args, **kwargs)¶
-
RPC database methods
-
class
iceprod.server.dbmethods.rpc.rpc(parent)[source]¶ The RPC DB methods.
-
rpc_new_task(*args, **kwargs)[source]¶ Get new task(s) from the queue specified by the gridspec, based on the hostname, network interfaces, resources. Save hostname,network in nodes table.
Returns: a list of job configs (dicts) Return type: list
-
rpc_set_processing(task_id)[source]¶ Set a task to the processing status
Parameters: task_id (str) – task_id
-
rpc_task_error(*args, **kwargs)[source]¶ Mark task as ERROR and possibly adjust resources.
Parameters:
-
rpc_stillrunning(*args, **kwargs)[source]¶ Check that the task is still in a running state.
Running states are “queued” or “processing”. Queued is allowed because of possible race conditions around changing status to processing.
Parameters: task_id – task id Returns: True or False Return type: bool
-
rpc_get_groups(*args, **kwargs)[source]¶ Get all the groups.
Returns: {group_id: group} Return type: dict
-
rpc_get_user_roles(*args, **kwargs)[source]¶ Get the roles a username belongs to.
Parameters: username (str) – user name Returns: {role_id: role} Return type: dict
-
rpc_queue_master(*args, **kwargs)[source]¶ Handle global queueing request from a site.
For a task to queue on a site, it must be matched in the dataset gridspec list (or the list should be empty to match all), and the necessary resources should be available on the site.
Parameters: - resources (dict) – (optional) the available resources on the site
- filters (dict) – (optional) group filters on the site
- queueing_factor_priority (float) – (optional) queueing factor for priority
- queueing_factor_dataset (float) – (optional) queueing factor for dataset id
- queueing_factor_tasks (float) – (optional) queueing factor for number of tasks
- num (int) – (optional) number of tasks to queue
Returns: table entries to be merged
Return type:
-
rpc_master_get_tables(*args, **kwargs)[source]¶ Get a dump of selected tables from the master.
Parameters: tablenames (iterable) – An iterable of table names. Returns: Dictionary of tables Return type: dict
-
Website database methods
-
class
iceprod.server.dbmethods.web.web(parent)[source]¶ The website DB methods.
-
web_get_tasks_by_status(*args, **kwargs)[source]¶ Get the number of tasks in each state on this site and plugin.
Parameters: Returns: {status:num}
Return type:
-
web_get_datasets(*args, **kwargs)[source]¶ Get the number of datasets in each state on this site and plugin.
Filters are specified as key=[‘match1’,’match2’]
Parameters: Returns: [{dataset}]
Return type:
-
web_get_datasets_details(*args, **kwargs)[source]¶ Get the number of datasets in each state on this site and plugin.
Parameters: Returns: {status:num}
Return type:
-
web_get_tasks_details(*args, **kwargs)[source]¶ Get the number of tasks in each state on this site and plugin.
Parameters: Returns: {status:num}
Return type:
-
web_get_logs(*args, **kwargs)[source]¶ Get the logs for a task.
Parameters: Returns: {log_name:text}
Return type:
-
web_get_gridspec(*args, **kwargs)[source]¶ Get the possible gridspecs that we know about.
Returns: {gridspecs} Return type: dict
-
web_get_dataset_by_name(*args, **kwargs)[source]¶ Get a dataset by its name.
Parameters: name (str) – dataset name Returns: dataset id Return type: str
-
web_get_task_completion_stats(*args, **kwargs)[source]¶ Get the task completion stats for a dataset.
- Columns:
- task_name task_type num_queued num_running num_completions avg_runtime max_runtime min_runtime error_count efficiency
Parameters: dataset_id (str) – dataset id Returns: {task_name: {column: num} } Return type: dict
-
web_get_job_counts_by_status(*args, **kwargs)[source]¶ Get count of jobs by status.
Parameters: Returns: {status: count}
Return type:
-
Node database methods
-
class
iceprod.server.dbmethods.node.node(parent)[source]¶ The node DB methods.
Takes a handle to a subclass of iceprod.server.modules.db.DBAPI as an argument.
Cron database methods
-
class
iceprod.server.dbmethods.cron.cron(parent)[source]¶ The scheduled (cron) DB methods.
Takes a handle to a subclass of iceprod.server.modules.db.DBAPI as an argument.
-
cron_dataset_completion(*args, **kwargs)[source]¶ Check for newly completed datasets and mark them as such
-
cron_job_completion(*args, **kwargs)[source]¶ Check for job status changes.
If this is the master, mark jobs complete, suspended, or failed as necessary. Completed jobs also delete the job temp space.
If this is not the master, and if all tasks in a job are not in an active state, then delete the job and tasks.
-
cron_clean_completed_jobs(*args, **kwargs)[source]¶ Check old files in the dagtemp from completed jobs
-
cron_check_active_pilots_tasks(*args, **kwargs)[source]¶ Reset processing tasks that are not listed as running by an active pilot.
-
Misc database methods
-
class
iceprod.server.dbmethods.misc.misc(parent)[source]¶ misc DB methods.
Takes a handle to a subclass of iceprod.server.modules.db.DBAPI as an argument.
-
misc_get_tables_for_task(*args, **kwargs)[source]¶ Get all tables necessary to run task(s).
Parameters: task_ids (iterable) – An iterable of task_ids Returns: table entries Return type: dict
-
misc_update_tables(*args, **kwargs)[source]¶ Update the DB tables with the incoming information.
Parameters: tables (dict) – {table_name:{keys:[],values:[[]]}} Returns: success or failure Return type: bool
-