slycat.web.client

class slycat.web.client.ArgumentParser(*arguments, **keywords)[source]

Bases: argparse.ArgumentParser

Return an instance of argparse.ArgumentParser, pre-configured with arguments to connect to a Slycat server.

parse_args()[source]
class slycat.web.client.Connection(host='http://localhost:8092', **keywords)[source]

Bases: object

Encapsulates a set of requests to the given host. Additional keyword arguments must be compatible with the Python Requests library, http://docs.python-requests.org/en/latest

delete_model(mid)[source]

Delete an existing model.

Parameters:mid (string, required) – The unique model identifier.

See also

DELETE /models/(mid)

delete_project(pid)[source]

Delete an existing project.

Parameters:pid (string, required) – The unique project identifier.

See also

DELETE /projects/(pid)

delete_project_cache_object(pid, key)[source]

Delete an existing project cache object.

Parameters:
  • pid (string, required) – The unique project identifier.
  • key (string, required) – Unique cache object key.

See also

DELETE /projects/(pid)/cache/(key)

delete_reference(rid)[source]

Delete an existing reference.

Parameters:rid (string, required) – The unique reference identifier.

See also

DELETE /references/(rid)

delete_remote(sid)[source]

Delete an existing remote session.

Parameters:sid (string, required) – The unique remote session identifier.

See also

DELETE /remotes/(sid)

find_or_create_project(name, description='')[source]

Return a project identified by name, or newly created.

Parameters:
  • name (string, required) – The name of the project to return (or create).
  • description (string, optional) – Description to use for the new project (if a new project is created).
Returns:

pid – Unique identifier of the matching (or newly created) project.

Return type:

string

Raises:

Exception – If more than one project matches the given name.

See also

post_projects()

find_project(name)[source]

Return a project identified by name.

Parameters:name (string, required) – The name of the project to return.
Returns:project
Return type:The matching project, which is an arbitrary collection of JSON-compatible data.
Raises:Exception – If a project with a matching name can’t be found, or more than one project matches the name.
get_bookmark(bid)[source]

Retrieve an existing bookmark.

Parameters:bid (string, required) – The unique bookmark identifier.
Returns:bookmark – The bookmark object, which is an arbitrary collection of JSON-compatible data.
Return type:object
get_configuration_markings()[source]

Retrieve marking information from the server.

Returns:markings
Return type:server marking information.

See also

GET /configuration/markings

get_configuration_parsers()[source]

Retrieve parser plugin information from the server.

Returns:parsers
Return type:server parser plugin information.

See also

GET /configuration/parsers

get_configuration_remote_hosts()[source]

Retrieve remote host information from the server.

Returns:parsers
Return type:server remote host information.

See also

GET /configuration/remote-hosts

get_configuration_support_email()[source]

Retrieve support email information from the server.

Returns:parsers
Return type:server support email information.

See also

GET /configuration/support-email

get_configuration_version()[source]

Retrieve version information from the server.

Returns:version
Return type:server version information.

See also

GET /configuration/version

get_configuration_wizards()[source]

Retrieve wizard plugin information from the server.

Returns:version
Return type:server wizard plugin information.

See also

GET /configuration/wizards

get_global_resource(resource)[source]
get_model(mid)[source]

Retrieve an existing model.

Parameters:mid (string, required) – The unique model identifier
Returns:model – The model object, which is an arbitrary collection of JSON-compatible data.
Return type:object

See also

GET /models/(mid)

get_model_arrayset_metadata(mid, aid, arrays=None, statistics=None, unique=None)[source]

Retrieve metadata describing an existing model arrayset artifact.

Parameters:
  • mid (string, required) – The unique model identifier.
  • aid (string, required) – The unique artifact identifier.
  • arrays (string, optional) – A set of arrays, specified using HQL.
  • statistics (string, optional) – A set of attributes, specified using HQL.
  • unique (string, optional) – A set of attributes, specified using HQL.
Returns:

metadata – The arrayset metadata, which is an arbitrary collection of JSON-compatible data.

Return type:

object

See also

GET /models/(mid)/arraysets/(aid)/metadata

get_model_file(mid, aid)[source]
get_model_parameter(mid, aid)[source]

Retrieve a model parameter artifact.

Model parameters are JSON objects of arbitrary complexity. They are stored directly within the model as part of its database record, so they should be limited in size (larger data should be stored using arraysets or files).

Parameters:
  • mid (string, required) – Unique model identifier.
  • aid (string, required) – Unique (within the model) artifact id.
Returns:

parameter

Return type:

JSON-compatible object

get_model_resource(mtype, resource)[source]
get_project(pid)[source]

Retrieve an existing project.

Parameters:pid (string, required) – Unique project identifier.
Returns:project
Return type:Arbitrary collection of JSON-compatible data.

See also

GET /projects/(pid)

get_project_cache_object(pid, key)[source]

Retrieve an object from a project cache.

Parameters:
  • pid (string, required) – Unique project identifier.
  • key (string, required) – Cache object identifier.
Returns:

content

Return type:

Cached object content.

See also

GET /projects/(pid)/cache/(key)

get_project_models(pid)[source]

Returns every model in a project.

get_project_references(pid)[source]

Returns every reference in a project.

get_projects()[source]

Retrieve all projects.

Returns:projects
Return type:List of projects. Each project is an arbitrary collection of JSON-compatible data.

See also

GET /projects

get_remote_file(sid, path, cache=None, project=None, key=None)[source]

Retrieve a file using a remote session.

Parameters:
  • sid (string, required) – Unique remote session identifier.
  • path (string, required) – Remote filesystem path (must be absolute).
  • cache (string, optional) – Optional server-side cache for the retrieved file. Must be None or “project”.
  • project (string, optional) – If cache is set to “project”, this must specify a unique project identifier.
  • key (string, optional) – if cache is set to “project”, this must specify a unique key for the cached object.
Returns:

file

Return type:

Remote file contents.

See also

GET /remotes/(sid)/file(path)

get_remote_image(sid, path, cache=None, project=None, key=None)[source]

Retrieve an image using a remote session.

Parameters:
  • sid (string, required) – Unique remote session identifier.
  • path (string, required) – Remote filesystem path (must be absolute).
  • cache (string, optional) – Optional server-side cache for the retrieved image. Must be None or “project”.
  • project (string, optional) – If cache is set to “project”, this must specify a unique project identifier.
  • key (string, optional) – if cache is set to “project”, this must specify a unique key for the cached object.
Returns:

image

Return type:

Remote image contents.

get_user(uid=None)[source]

Retrieve directory information about an existing user.

Parameters:uid (string, optional) – Unique user identifier. If unspecified, returns information about the user making the call.
Returns:user
Return type:Arbitrary collection of JSON-compatible data.

See also

GET /users/(uid)

get_wizard_resource(wtype, resource)[source]
join_model(mid)[source]

Wait for a model to complete before returning.

A Slycat model goes through several distinct phases over its lifetime:

  1. The model is created.
  2. Input artifacts are pushed into the model.
  3. The model is marked “finished”.
  4. Optional one-time computation is performed on the server, storing output artifacts.
  5. The model is complete and ready to be viewed.

Use this function in scripts that have performed steps 1, 2, and 3 and need to wait until step 4 completes.

Parameters:mid (string, required) – Unique model identifier.

Notes

A model that hasn’t been finished will never complete - you should ensure that post_model_finish() is called successfully before calling join_model().

post_events(path, parameters={})[source]
post_model_files(mid, aids, files, parser, input=True, parameters={})[source]

Stores a model file artifacts.

post_model_finish(mid)[source]

Notify the server that a model is fully initialized.

When called, the server will perform one-time computation for the given model type.

Parameters:mid (string, required) – Unique model identifier.
post_project_bookmarks(pid, bookmark)[source]

Store a bookmark.

Parameters:
  • pid (string, required) – Unique project identifier.
  • bookmark (object) – Arbitrary collection of JSON-compatible data.
Returns:

bid – Unique bookmark identifier.

Return type:

string

post_project_models(pid, mtype, name, marking='', description='')[source]

Creates a new model, returning the model ID.

post_project_references(pid, name, mtype=None, mid=None, bid=None)[source]

Store a project reference.

Parameters:
  • pid (string, required) – Unique project identifier.
  • name (string, required) – Reference name.
  • mtype (string, optional) – Optional model type.
  • mid (string, optional) – Optional model identifier.
  • bid (string, optional) – Optional bookmark identifier.
Returns:

rid – Unique reference identifier.

Return type:

string

See also

POST /projects/(pid)/references

post_projects(name, description='')[source]

Creates a new project, returning the project ID.

post_remote_browse(sid, path, file_reject=None, file_allow=None, directory_allow=None, directory_reject=None)[source]
post_remotes(hostname, username, password, agent=None)[source]
put_model(mid, model)[source]
put_model_arrayset(mid, aid, input=True)[source]

Starts a new model array set artifact, ready to receive data.

put_model_arrayset_array(mid, aid, array, dimensions, attributes)[source]

Starts a new array set array, ready to receive data.

put_model_arrayset_data(mid, aid, hyperchunks, data, force_json=False)[source]

Write data to an arrayset artifact on the server.

Parameters:
  • mid (string, required) – Unique model identifier.
  • aid (string, required) – Unique (to the model) arrayset artifact id.
  • hyperchunks (string, required) – Specifies where the data will be stored, in Hyperchunks format.
  • data (iterable, required)) – A collection of numpy.ndarray data chunks to be uploaded. The number of data chunks must match the number implied by the hyperchunks parameter.
  • force_json (bool, optional)) – Force the client to upload data using JSON instead of the binary format.
put_model_inputs(source, target)[source]
put_model_parameter(mid, aid, value, input=True)[source]

Store a model parameter artifact.

Model parameters are JSON objects of arbitrary complexity. They are stored directly within the model as part of its database record, so they should be limited in size (larger data should be stored using arraysets or files).

To get the value of a parameter artifact, use get_model() and read the value directly from the model record. An artifact id foo will be accessible in the record as model[“artifact:foo”].

Parameters:
  • mid (string, required) – Unique model identifier.
  • aid (string, required) – Unique (within the model) artifact id.
  • value (object, required) – An arbitrary collection of JSON-compatible data.
  • input (boolean, optional) – Marks whether this artifact is a model input.
put_project(pid, project)[source]

Modifies a project.

request(method, path, **keywords)[source]

Makes a request with the given HTTP method and path, returning the body of the response. Additional keyword arguments must be compatible with the Python Requests library, http://docs.python-requests.org/en/latest

update_model(mid, **kwargs)[source]

Update model state.

This function provides a more convenient alternative to put_model().

See also

put_model()

slycat.web.client.connect(arguments, **keywords)[source]

Factory function for client connections that takes an option parser as input.