datmo.snapshot module

class datmo.snapshot.Snapshot(snapshot_entity)[source]

Snapshot is an entity object to enable user access to properties

Parameters:snapshot_entity (datmo.core.entity.snapshot.Snapshot) – core snapshot entity to reference
id

the id of the entity

Type:str
model_id

the parent model id for the entity

Type:str
message

long description of snapshot

Type:str
code_id

code reference associated with the snapshot

Type:str
environment_id

id for environment used to create snapshot

Type:str
file_collection_id

file collection associated with the snapshot

Type:str
config

key, value pairs of configurations

Type:dict
stats

key, value pairs of metrics and statistics

Type:dict
task_id

task id associated with snapshot

Type:str
label

short description of snapshot

Type:str
created_at
Type:datetime.datetime
Raises:InvalidArgumentType
files
get_files(mode='r')[source]

Returns a list of file objects for the snapshot

Parameters:mode (str) – file object mode (default is “r” which signifies read mode)
Returns:list of file objects associated with the snapshot
Return type:list
datmo.snapshot.create(message, label=None, run_id=None, environment_id=None, env=None, paths=None, config=None, stats=None)[source]

Create a snapshot within a project

The project must be created before this is implemented. You can do that by using the following command:

$ datmo init
Parameters:
  • message (str) – a description of the snapshot for later reference
  • label (str, optional) – a short description of the snapshot for later reference (default is None, which means a blank label is stored)
  • run_id (str, optional) –

    run object id to use to create snapshot if run id is passed then subsequent parameters would be ignored. when using run id, it will overwrite the following inputs

    environment_id: used to run the task,

    paths: this is the set of all files saved during the task

    config: nothing is passed into this variable. the user may add something to the config by passing in a dict for the config

    stats: the task.results are added into the stats variable of the snapshot.

  • environment_id (str, optional) – provide the environment object id to use with this snapshot (default is None, which means it creates a default environment)
  • env (str or list, optional) – the absolute file path for the environment definition path. env is not used if environment_id is also passed. this can be either a string or list (default is None, environment_id is also not passed, which will defer to the environment to find a default environment or will fail if not found)
  • paths (list, optional) – list of absolute or relative filepaths and/or dirpaths to collect with destination names (e.g. “/path/to/file>hello”, “/path/to/file2”, “/path/to/dir>newdir”)
  • config (dict, optional) – provide the dictionary of configurations (default is None, which means it is empty)
  • stats (dict, optional) – provide the dictionary of relevant statistics or metrics (default is None, which means it is empty)
Returns:

returns a Snapshot entity as defined above

Return type:

Snapshot

Examples

You can use this function within a project repository to save snapshots for later use. Once you have created this, you will be able to view the snapshot with the datmo snapshot ls cli command

>>> import datmo
>>> datmo.snapshot.create(message="my first snapshot", paths=["/path/to/a/large/file"], config={"test": 0.4, "test2": "string"}, stats={"accuracy": 0.94})

You can also use the result of a task run in order to create a snapshot

>>> datmo.snapshot.create(message="my first snapshot from task", task_id="1jfkshg049")
datmo.snapshot.delete(snapshot_id=None)[source]

Delete a snapshot within a project

The project must be created before this is implemented. You can do that by using the following command:

$ datmo init
Parameters:snapshot_id (str) – snapshot id to be updated
Returns:returns a Snapshot entity
Return type:snapshot entity

Examples

You can use this function within a project repository to delete a snapshot.

>>> import datmo
>>> datmo.snapshot.delete(snapshot_id="4L24adFfsa")
datmo.snapshot.ls(filter=None)[source]

List snapshots within a project

The project must be created before this is implemented. You can do that by using the following command:

$ datmo init
Parameters:filter (str, optional) – a string to use to filter from message and label (default is to give all snapshots, unless provided a specific string. eg: best)
Returns:returns a list of Snapshot entities (as defined above)
Return type:list

Examples

You can use this function within a project repository to list snapshots.

>>> import datmo
>>> snapshots = datmo.snapshot.ls()
datmo.snapshot.update(snapshot_id=None, config=None, stats=None, message=None, label=None)[source]

Update a snapshot within a project

The project must be created before this is implemented. You can do that by using the following command:

$ datmo init
Parameters:
  • snapshot_id (str) – snapshot id to be updated
  • config (dict, optional) – provide the dictionary of configurations to update (default is None, which means it is not being updated)
  • stats (dict, optional) – provide the dictionary of relevant statistics or metrics to update (default is None, which means it is not being updated)
  • message (str, optional) – a string to use as a new message for the snapshot (default is the already given message to that snapshot, unless provided a specific string.)
  • label (str, optional) – a string to use as a new label for the snapshot (default is the already given label to that snapshot, unless provided a specific string.)
Returns:

returns a Snapshot entity

Return type:

snapshot entity

Examples

You can use this function within a project repository to update a snapshot.

>>> import datmo
>>> snapshots = datmo.snapshot.update(snapshot_id="4L24adFfsa", config={"depth": "10", "learning_rate": "0.91"},
...          stats={"acc": "91.34", "f1_score": "0.91"}, message="new message", label="best")