datmo.snapshot module¶
-
class
datmo.snapshot.
Snapshot
(snapshot_entity, home=None)[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
- home (str, optional) – root directory of the project (default is CWD, if not provided)
-
id
¶ str – the id of the entity
-
model_id
¶ str – the parent model id for the entity
-
session_id
¶ str – id of session associated with task
-
id
str – the id of the entity
-
model_id
str – the parent model id for the entity
-
session_id
str – session id within which snapshot is created
-
message
¶ str – long description of snapshot
-
code_id
¶ str – code reference associated with the snapshot
-
environment_id
¶ str – id for environment used to create snapshot
-
file_collection_id
¶ str – file collection associated with the snapshot
-
config
¶ dict – key, value pairs of configurations
-
stats
¶ dict – key, value pairs of metrics and statistics
-
task_id
¶ str – task id associated with snapshot
-
label
¶ str – short description of snapshot
-
created_at
¶ datetime.datetime
Raises: InvalidArgumentType
-
files
¶
-
datmo.snapshot.
create
(message, label=None, home=None, task_id=None, commit_id=None, environment_id=None, filepaths=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)
- home (str, optional) – absolute home path of the project (default is None, which will use the CWD as the project path)
- task_id (str, optional) –
task object id to use to create snapshot if task id is passed then subsequent parameters would be ignored. when using task id, it will overwrite the following inputs
commit_id: taken form the source code after the task is run
environment_id: used to run the task,
filepaths: 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.
- commit_id (str, optional) – provide the exact commit hash associated with the snapshot (default is None, which means it automatically creates a commit)
- environment_id (str, optional) – provide the environment object id to use with this snapshot (default is None, which means it creates a default environment)
- filepaths (list, optional) – provides a list of absolute filepaths to files or directories that are relevant (default is None, which means we have an empty
- 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: 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", filepaths=["/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.
ls
(session_id=None, filter=None, home=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: - session_id (str, optional) – session to filter output snapshots (default is None, which means no session filter is given)
- 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)
- home (str, optional) – absolute home path of the project (default is None, which will use the CWD as the project path)
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()