comet_ml.APIExperiment ¶
The APIExperiment class is used to access data from the Comet.ml Python API.
You can use an instance of the APIExperiment() class to easily access all of your logged experiment information at Comet, including metrics, parameters, tags, and assets. The following examples assume your This example shows looking up an experiment by its URL: You can also make a new experiment using the API: Here is an end-to-end snippet to rename a metric. You can use this basic structure for logging new metrics (after the experiment has completed) such as averages or scaling to a baseline. For more usage examples, see Comet Python API examples.Example
COMET_API_KEY
is configured as per Python Configuration.>>> from comet_ml.api import API, APIExperiment
## (assumes api keys are configured):
>>> api = API() # can also: API(api_key="...")
## Get an APIExperiment from the API:
>>> experiment = api.get("cometpublic/comet-notebooks/example 001")
## Make a new APIExperiment (assumes api keys are configured):
>>> experiment = APIExperiment(workspace="my-username",
project_name="general")
from comet_ml import API
WORKSPACE = "your-comet-id"
PROJECT_NAME = "general"
EXP_KEY = "your-experiment-key"
OLD_METRIC_NAME = "loss"
NEW_METRIC_NAME = "train_loss"
api = API() # can also: API(api_key="...")
experiment = api.get_experiment(WORKSPACE, PROJECT_NAME, EXP_KEY)
old_metrics = experiment.get_metrics(OLD_METRIC_NAME)
for old_metric in old_metrics:
experiment.log_metric(
NEW_METRIC_NAME,
old_metric["metricValue"],
step=old_metric["step"],
timestamp=old_metric["timestamp"],
)
Attributes¶
key property
¶
key
Get the experiment key (the unique id).Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(workspace=WORKSPACE)
print(api_experiment.key)
name property
writable
¶
name
Get the experiment name.Example
1
2
3
4
5
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(workspace=WORKSPACE)
print(api_experiment.name)
url property
¶
url
Get the url of the experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(workspace=WORKSPACE)
print(api_experiment.url)
Functions¶
__init__ ¶
__init__(*args, **kwargs)
Create a new APIExperiment, or use a previous experiment key to access an existing experiment. api_key may be defined in environment (COMET_API_KEY) or in a .comet.config file. Additional arguments will be given to API().Example
1
2
3
4
5
6
7
8
9
10
11
import comet_ml
comet_ml.login()
# Python API to create a new experiment:
experiment = comet_ml.APIExperiment(workspace=WORKSPACE,
project_name=PROJECT)
# Python API to access an existing experiment:
# (assumes api keys are configured):
experiment = comet_ml.APIExperiment(previous_experiment=EXPERIMENT_KEY)
Note
add_tag ¶
add_tag(tag: str) -> Dict[str, Any]
Append onto an experiment's list of tags.
Parameters:
tag
(str
) –A tag.
Example
1 2 3 4 5 6 |
|
add_tags ¶
add_tags(tags: List[str]) -> Dict[str, Any]
Append onto an experiment's list of tags.
Parameters:
tags
(List[str]
) –A list of tags (strings).
Example
1 2 3 4 5 6 |
|
archive ¶
archive()
Archive this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
api_experiment.archive()
create_symlink ¶
create_symlink(project_name)
Create a copy of this experiment in another project in the workspace.
Parameters:
project_name
(str
) –the name of the project with which to create a symlink to this experiment in.
Example
1 2 3 4 5 6 |
|
delete_asset ¶
delete_asset(asset_id)
Delete an experiment's asset.
Parameters:
asset_id
(str
) –The asset id of the asset to delete.
delete_parameter ¶
delete_parameter(parameter: str) -> bool
Delete parameter from an experiment.
Parameters:
parameter
(str
) –string, parameter name
>>> api_experiment.delete_parameter("learning_rate")
delete_parameters ¶
delete_parameters(parameters: List[str]) -> bool
Delete parameter from an experiment.
Parameters:
parameters
(List[str]
) –list of strings, parameter names
>>> api_experiment.delete_parameters(["learning_rate", "layers"])
delete_tags ¶
delete_tags(tags: List[str]) -> Dict[str, Any]
Delete from an experiment the list of tags.
Parameters:
tags
(List[str]
) –A list of tags (strings).
Example
1 2 3 4 5 6 |
|
download_model ¶
download_model(name, output_path='./', expand=True)
Download and save all files from the model.
Parameters:
name
(str
) –The name of the model.
output_path
(str
, default:'./'
) –The output directory; defaults to current directory.
expand
(bool
, default:True
) –If True, the downloaded zipfile is unzipped; if False, then the zipfile is copied to the output_path.
download_tensorflow_folder ¶
download_tensorflow_folder(output_path='./', overwrite=False)
Download all files logged with comet_ml.Experiment.log_tensorflow_folder.
Parameters:
output_path
(str
, default:'./'
) –Where to download the files
overwrite
(bool
, default:False
) –If True, then overwrite any file that exists
Example
1 2 3 4 5 6 7 8 9 10 |
|
get_additional_system_info ¶
get_additional_system_info()
Get the associated additional system info for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_additional_system_info())
get_artifact_lineage ¶
get_artifact_lineage(direction: str = 'all') -> Dict[str, Any]
Get the artifact lineage filtered using direction
parameter.
Parameters:
direction
(str
, default:'all'
) –String representing filtering criteria to be applied to the artifact's lineage before returning. Allowed values: 'all', 'output', or 'input'.
Example
1 2 3 4 5 6 |
|
get_asset ¶
get_asset(asset_id, return_type='binary', stream=False)
Get an asset, given the asset_id.
Parameters:
asset_id
(str
) –The asset ID
return_type
(str
, default:'binary'
) –The type of object returned. Default is "binary". Options: "binary", "json", or "response"
stream
(bool
, default:False
) –When return_type is "response", you can also use stream=True to use the response as a stream
Example
1 2 3 4 5 6 |
|
To use with the streaming option:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
get_asset_by_name ¶
get_asset_by_name(
asset_filename, asset_type="all", return_type="binary", stream=False
)
Get an asset, given the asset filename.
Parameters:
asset_filename
(str
) –The asset filename.
asset_type
(str
, default:'all'
) –Type of asset to return. Can be "all", "image", "histogram_combined_3d", "video", or "audio".
return_type
(str
, default:'binary'
) –The type of object returned. Default is "binary". Options: "binary", "json", or "response"
stream
(bool
, default:False
) –When return_type is "response", you can also use stream=True to use the response as a stream
the same name. If you give the asset_type, the function will run faster. If no asset is found, then the method returns None.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
api_experiment.get_asset_by_name("features.json", return_type="json")
get_asset_list ¶
get_asset_list(asset_type='all')
Get a list of assets associated with the experiment.
Parameters:
asset_type
(str
, default:'all'
) –Type of asset to return. Can be "all", "image", "histogram_combined_3d", "video", or "audio".
Returns:
dict
–A list of dictionaries of asset properties
Example
Getting all metrics for an experiment:
1 2 3 4 5 6 7 |
|
will print the following list:
[{
'fileName': 'My Filename.png',
'fileSize': 21113,
'runContext': None,
'step': None,
'link': 'https://www.comet.com/api/asset/download?experimentKey=KEY&assetId=ASSET_ID',
'createdAt': 1565898755830,
'dir': 'assets',
'canView': False,
'audio': False,
'video': False,
'histogram': False,
'image': True,
'type': 'image',
'metadata': None,
'assetId': ASSET_ID
},
...]
get_code ¶
get_code()
Get the associated source code for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_code())
get_command ¶
get_command()
Get the associated command-line script and args for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_command())
get_curve ¶
get_curve(asset_id)
Get curve logged with experiment by asset id.
Parameters:
asset_id
(str
) –The asset id of the curve to download
Example
Running the code sample:
1 2 3 4 5 6 |
|
Will return the dictionary:
{
"name": "curve1",
"x": [1, 2, 3],
"y": [4, 5, 6], "step": 0
}
get_curves ¶
get_curves()
Get all curves logged with experiment. Will return the dictionary:Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
api_experiment.get_curves()
[{
"name": "curve1",
"x": [1, 2, 3],
"y": [4, 5, 6], "step": 0
}]
get_environment_details ¶
get_environment_details()
Deprecated. Use comet_ml.APIExperiment.get_os_packages instead.
get_executable ¶
get_executable()
Get the associated executable for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_executable())
get_git_metadata ¶
get_git_metadata()
Get the git-metadata associated with this experiment. Running the code sample" will return the json:Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
api_experiment.get_git_metadata()
{
"branch": 'refs/heads/master',
"origin": 'git@github.com:comet-ml/comet-examples.git',
"parent": '96ff529b4c02e4e0bb92992a7c4ce81275985764',
"root": 'eec2d16daa057d0cf4c2c49974e6ea51e732a7b2',
"user": 'user',
}
get_git_patch ¶
get_git_patch()
Get the git-patch associated with this experiment as a zipfile containing a unique file named zip_file.patch
.Example
1
2
3
4
5
6
7
8
9
import io, zipfile
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
zip_patch = io.BytesIO(api_experiment.get_git_patch())
archive = zipfile.ZipFile(zip_patch)
patch = archive.read("git_diff.patch")
get_gpu_static_info ¶
get_gpu_static_info()
Get the associated GPU static info for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_gpu_statis_info())
get_hostname ¶
get_hostname()
Get the associated hostname for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_hostname())
get_html ¶
get_html()
Get the HTML associated with this experiment.Example
1
2
3
4
5
6
7
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(workspace=WORKSPACE)
api_experiment.log_html("<b>Hello, world!</b>")
print(api_experiment.get_html())
get_installed_packages ¶
get_installed_packages()
Get the associated installed packages for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_installed_packages())
get_ip ¶
get_ip()
Get the associated IP for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_ip())
get_machine ¶
get_machine()
Get the associated total RAM for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_machine())
get_max_memory ¶
get_max_memory()
Get the associated max total memory for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_max_memory())
get_metadata ¶
get_metadata()
Get the metadata associated with this experiment. Running the following code sample: will print the following dictionary:Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
metadata = api_experiment.get_metadata()
{
'archived': False,
'durationMillis': 7,
'endTimeMillis': 1586174765277,
'experimentKey': 'EXPERIMENT-KEY',
'experimentName': None,
'fileName': None,
'filePath': None,
'optimizationId': None,
'projectId': 'PROJECT-ID',
'projectName': 'PROJECT-NAME',
'running': False,
'startTimeMillis': 1586174757596,
'throttle': False,
'workspaceName': 'WORKSPACE-NAME',
}
get_metrics ¶
get_metrics(metric=None)
Get all of the logged metrics. Optionally, just get the given metric name.
Parameters:
metric
(str
, default:None
) –If given, filter the metrics by name.
Example
Getting all metrics for an experiment:
1 2 3 4 5 6 7 |
|
will print the following list:
[{
'metricName': 'val_loss',
'metricValue': '0.13101346811652184',
'timestamp': 1558962376383,
'step': 1500,
'epoch': None,
'runContext': None
},
{
'metricName': 'acc',
'metricValue': '0.876',
'timestamp': 1564536453647,
'step': 100,
'epoch': None,
'runContext': None
},
...]
Specifying the metric name:
1 2 3 4 5 6 7 |
|
will print the following dictionary:
[{
'metricName': 'acc',
'metricValue': '0.876',
'timestamp': 1564536453647,
'step': 100,
'epoch': None,
'runContext': None
},
...]
get_metrics_summary ¶
get_metrics_summary(metric=None)
Return the experiment metrics summary. Optionally, also if you provide the metric name, the function will only return the summary of the metric.
Parameters:
metric
(str
, default:None
) –Name of a metric.
Example
Getting all metrics for an experiment:
1 2 3 4 5 6 7 |
|
will print the following list:
[{
'name': 'val_loss',
'valueMax': '0.24951280827820302',
'valueMin': '0.13101346811652184',
'valueCurrent': '0.13101346811652184',
'timestampMax': 1558962367938,
'timestampMin': 1558962367938,
'timestampCurrent': 1558962376383,
'stepMax': 500,
'stepMin': 1500,
'stepCurrent': 1500
},
...]
Specifying the metric name:
1 2 3 4 5 6 7 |
|
will print the following dictionary:
{
'name': 'val_loss',
'valueMax': '0.24951280827820302',
'valueMin': '0.13101346811652184',
'valueCurrent': '0.13101346811652184',
'timestampMax': 1558962367938,
'timestampMin': 1558962367938,
'timestampCurrent': 1558962376383,
'stepMax': 500,
'stepMin': 1500,
'stepCurrent': 1500
}
get_model_asset_list ¶
get_model_asset_list(model_name)
Get an experiment model's asset list by model name.
Parameters:
model_name
(str
) –The name of the model.
Returns:
dict
–A list of asset dictionaries with these fields: fileName, fileSize, runContext, step, link, createdAt, dir, canView, audio, histogram, image, type, metadata, assetId
Example
Running the following code:
1 2 3 4 5 6 7 8 |
|
will display the dictionary:
[
{
"assetId": 74374637463476,
"audio": False,
"canView": False,
"createdAt": 7337347634,
"dir": "trained-models",
"fileName": "model.h5",
"fileSize": 254654,
"histogram": False,
"image": False,
"link": "https://link-to-download-asset-file",
"metadata": None,
"remote": False,
"runContext": "train",
"step": 54,
"type": "asset",
}
]
get_model_data ¶
get_model_data(name)
Deprecated. Use comet_ml.APIExperiment.get_model_asset_list instead.
get_model_graph ¶
get_model_graph()
Get the associated graph/model description for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_model_graph())
get_model_names ¶
get_model_names()
Get a list of model names associated with this experiment.
Returns:
list
–List of model names
get_name ¶
get_name()
Get the name of the experiment, if one.Example
1
2
3
4
5
6
7
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(workspace=WORKSPACE)
api_experiment.set_name("My Name")
print(api_experiment.get_name())
get_network_interface_ips ¶
get_network_interface_ips()
Get the associated network interface IPs for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_netword_interface_ips())
get_os ¶
get_os()
Get the associated OS for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_os())
get_os_packages ¶
get_os_packages()
Get the OS packages for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_os_packages())
get_os_release ¶
get_os_release()
Get the associated OS release for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_os_release())
get_os_type ¶
get_os_type()
Get the associated os type for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_os_type())
get_others_summary ¶
get_others_summary(other=None)
Get the other items logged in summary form.
Parameters:
other
(str
, default:None
) –The name of the other item logged. If given, return the valueCurrent of the other item. Otherwise, return all other items logged.
Example
Getting all metrics for an experiment:
1 2 3 4 5 6 7 |
|
will print the following list:
[{
'name': 'trainable_params',
'valueMax': '712723',
'valueMin': '712723',
'valueCurrent': '712723',
'timestampMax': 1558962363411,
'timestampMin': 1558962363411,
'timestampCurrent': 1558962363411
},
...]
Specifying the metric name:
1 2 3 4 5 6 7 |
|
will print the following dictionary:
['712723']
get_output ¶
get_output()
Get the associated standard output for this experiment.Example
1
2
3
4
5
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_output())
get_parameters_summary ¶
get_parameters_summary(parameter=None)
Return the experiment parameters summary. Optionally, also if you provide a parameter name, the method will only return the summary of the given parameter.
Parameters:
parameter
(str
, default:None
) –Name of a parameter
Example
Running the following code sample:
1 2 3 4 5 6 |
|
will print the list:
[{
'name': 'batch_size',
'valueMax': '120',
'valueMin': '120',
'valueCurrent': '120',
'timestampMax': 1558962363411,
'timestampMin': 1558962363411,
'timestampCurrent': 1558962363411
},
...]
Specifying a parameter name:
1 2 3 4 5 6 |
|
will return the dictionary:
{
'name': 'batch_size',
'valueMax': '120',
'valueMin': '120',
'valueCurrent': '120',
'timestampMax': 1558962363411,
'timestampMin': 1558962363411,
'timestampCurrent': 1558962363411
}
get_pid ¶
get_pid()
Get the pid for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_pid())
get_processor ¶
get_processor()
Get the associated total RAM for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_processor())
get_python_version ¶
get_python_version()
Get the Python version for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_python_version())
get_python_version_verbose ¶
get_python_version_verbose()
Get the Python version verbose for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_python_version_verbose())
get_state ¶
get_state() -> str
Get current state of experiment.
Returns:
str
(str
) –'running', 'finished' or 'crashed'
get_system_details ¶
get_system_details()
Get the system details associated with this experiment.
Returns:
dict
–A dictionary that follows the format:
{ "experimentKey": "someExperimentKey", "user": "system username" "pythonVersion": "python version" "pythonVersionVerbose": "python version with verbose flag" "pid": <Integer, pid>, "osType": "os experiment ran on", "os": "os with version info", "ip": "ip address", "hostname": "hostname", "gpuStaticInfoList": [ { "gpuIndex": <Integer, index>, "name": "name", "uuid": "someUniqueId", "totalMemory": <Integer, total memory>, "powerLimit": <Integer, max power> } ], "logAdditionalSystemInfoList": [ { "key": "someKey", "value": "someValue" } ], "systemMetricNames": ["name", "anotherName"], "maxTotalMemory": <double, max memory used>, "networkInterfaceIps": ["ip", "anotherIp"] "command": ["part1", "part2"], "executable": "The python Exe, if any (in future could be non python executables)", "osPackages": ["package", "anotherPackage"], "installedPackages": ["package", "anotherPackage"] }
get_system_metric_names ¶
get_system_metric_names()
Get the associated system metric names for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_system_metric_names())
get_tags ¶
get_tags()
Get the associated tags for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_tags())
get_total_memory ¶
get_total_memory()
Get the associated total RAM for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_total_memory())
get_user ¶
get_user()
Get the associated user for this experiment.Example
1
2
3
4
5
6
import comet_ml
comet_ml.login()
api_experiment = comet_ml.APIExperiment(previous_experiment='EXPERIMENT-KEY')
print(api_experiment.get_user())
log_additional_system_info ¶
log_additional_system_info(key, value)
Log additional system information for this experiment.
Parameters:
key
(str
) –The name for this system information.
value
(Any
) –The value of the system information.
Example
1 2 3 4 5 6 |
|
log_asset ¶
log_asset(
filename,
step=None,
name=None,
overwrite=None,
context=None,
ftype=None,
metadata=None,
)
Upload an asset to an experiment.
Parameters:
filename
(str
) –The name of the asset file to upload.
step
(int
, default:None
) –The current step.
overwrite
(bool
, default:None
) –If True, overwrite any previous upload.
context
(str
, default:None
) –The current context (e.g., "train" or "test").
ftype
(str
, default:None
) –the type of asset (e.g., "image", "histogram_combined_3d", "image", "audio", or "video").
metadata
(dict
, default:None
) –a JSON object to attach to image.
Example
1 2 3 4 5 6 |
|
log_cpu_metrics ¶
log_cpu_metrics(
cpu_metrics, context=None, step=None, epoch=None, timestamp=None
)
Log an instance of cpu_metrics.
Parameters:
cpu_metrics
(list
) –A list of integer percentages, ordered by cpu.
context
(str
, default:None
) –A run context.
step
(int
, default:None
) –The current step.
epoch
(int
, default:None
) –The current epoch.
timestamp
(int
, default:None
) –Current time, in milliseconds.
Example
1 2 3 4 5 6 |
|
log_curve ¶
log_curve(name, x, y, overwrite=False, step=None)
Log timeseries data.
Parameters:
name
(str
) –Name of data.
x
(list
) –List of x-axis values.
y
(list
) –List of y-axis values.
overwrite
(bool
, default:False
) –If True, overwrite previous log.
step
(int
, default:None
) –The step value
Example
1 2 3 4 5 6 7 |
|
log_gpu_metrics ¶
log_gpu_metrics(gpu_metrics)
Log an instance of gpu_metrics.
Parameters:
gpu_metrics
(list
) –A list of dicts with keys:
- gpuId: required, Int identifier
- freeMemory: required, Long
- usedMemory: required, Long
- gpuUtilization: required, Int percentage utilization
- totalMemory: required, Long
Example
1 2 3 4 5 6 7 8 9 10 11 12 |
|
log_html ¶
log_html(html, clear=False, timestamp=None)
Set, or append onto, an experiment's HTML.
Parameters:
html
(str
) –The HTML text to associate with this experiment.
clear
(bool
, default:False
) –If True, clear any previously logged HTML.
timestamp
(int
, default:None
) –The current time (in milliseconds).
Example
1 2 3 4 5 6 |
|
log_image ¶
log_image(
filename: str,
image_name: Optional[str] = None,
step: Optional[int] = None,
overwrite: Optional[bool] = None,
context: Optional[str] = None,
metadata: Optional[Dict[str, Any]] = None,
) -> Dict[str, Any]
Upload an image asset to an experiment.
Parameters:
filename
(str
) –The name of the image file to upload.
image_name
(str
, default:None
) –The name of the image.
step
(int
, default:None
) –The current step.
overwrite
(bool
, default:None
) –If True, overwrite any previous upload.
context
(str
, default:None
) –The current context (e.g., "train" or "test").
metadata
(dict
, default:None
) –Some additional data to attach to the image. Must be a JSON-compatible dict.
Example
1 2 3 4 5 6 |
|
log_load_metrics ¶
log_load_metrics(load_avg, context=None, step=None, epoch=None, timestamp=None)
Log an instance of system load metrics.
Parameters:
load_avg
(float
) –The load average.
context
(str
, default:None
) –The run context.
step
(int
, default:None
) –The current step.
epoch
(int
, default:None
) –The current epoch.
timestamp
(int
, default:None
) –The current timestamp in milliseconds.
Example
1 2 3 4 5 6 |
|
log_metric ¶
log_metric(
metric: str,
value: Any,
step: Optional[int] = None,
epoch: Optional[int] = None,
timestamp: Optional[int] = None,
)
Set a metric name/value pair for an experiment.
Parameters:
metric
(str
) –The name of the metric.
value
(Any
) –The value of the metric.
step
(int
, default:None
) –The current step.
epoch
(int
, default:None
) –The current epoch.
timestamp
(int
, default:None
) –The current timestamp in seconds.
Example
1 2 3 4 5 6 |
|
log_metrics ¶
log_metrics(
metric_dict: Dict[str, Any],
step: Optional[int] = None,
epoch: Optional[int] = None,
timestamp: Optional[int] = None,
)
Set a dictionary of metric name/value pairs for an experiment.
Parameters:
metric_dict
(dict
) –A dict in the form of {"metric_name": value, ...}.
step
(int
, default:None
) –The current step.
epoch
(int
, default:None
) –The current epoch.
timestamp
(int
, default:None
) –The current timestamp in milliseconds.
Example
1 2 3 4 5 6 |
|
log_other ¶
log_other(key, value, timestamp=None)
Set another key/value pair for an experiment.
Parameters:
key
(str
) –The name of the other information.
value
(Any
) –The value of the other information.
timestamp
(int
, default:None
) –optional, the current timestamp in milliseconds.
Example
1 2 3 4 5 6 |
|
log_output ¶
log_output(output, context=None, stderr=False, timestamp=None)
Log output line(s).
Parameters:
output
(str
) –String representing standard output or error.
context
(str
, default:None
) –The run context.
stderr
(bool
, default:False
) –If True, the lines are standard errors
timestamp
(int
, default:None
) –The current timestamp in milliseconds
Example
1 2 3 4 5 6 |
|
log_parameter ¶
log_parameter(
parameter: str,
value: Any,
step: Optional[int] = None,
timestamp: Optional[int] = None,
) -> Optional[Dict[str, Any]]
Set a parameter name/value pair for an experiment.
Parameters:
parameter
(str
) –The name of the parameter.
value
(Any
) –The value of the parameter.
step
(int
, default:None
) –The current step.
timestamp
(int
, default:None
) –The current timestamp in milliseconds.
Example
1 2 3 4 5 6 |
|
log_parameters ¶
log_parameters(
param_dict: Dict[str, Any],
step: Optional[int] = None,
timestamp: Optional[int] = None,
nested_support: bool = True,
) -> List[Optional[Dict[str, Any]]]
Set a dictionary of parameter name/value pairs for an experiment.
Parameters:
param_dict
(dict
) –Dict in the form of {"param_name": value, ...}.
step
(int
, default:None
) –The current step.
timestamp
(int
, default:None
) –The current timestamp in milliseconds.
nested_support
(bool
, default:True
) –Support nested parameters.
Example
1 2 3 4 5 6 |
|
log_ram_metrics ¶
log_ram_metrics(
total_ram, used_ram, context=None, step=None, epoch=None, timestamp=None
)
Log an instance of RAM metrics.
Parameters:
total_ram
(float
) –Total RAM available.
used_ram
(float
) –RAM used.
context
(str
, default:None
) –The run context.
step
(int
, default:None
) –The current step.
epoch
(int
, default:None
) –The current epoch.
timestamp
(int
, default:None
) –The current timestamp in millisconds.
Example
1 2 3 4 5 6 |
|
log_table ¶
log_table(
filename: str,
tabular_data: Optional[Any] = None,
headers: Union[Sequence[str], bool] = False,
**format_kwargs: Any
) -> Optional[Dict[str, str]]
Log tabular data, including data, csv files, tsv files, and Pandas dataframes.
Parameters:
filename
(str
) –A filename ending in ".csv", or ".tsv" (for tablular data) or ".json", ".csv", ".md", or ".html" (for Pandas dataframe data).
tabular_data
(Any
, default:None
) –Data that can be interpreted as 2D tabular data or a Pandas dataframe.
headers
(bool | list
, default:False
) –If True, will add column headers automatically if tabular_data is given; if False, no headers will be added; if list then it will be used as headers. Only useful with tabular data (csv, or tsv).
format_kwargs
(Any
, default:{}
) –When passed a Pandas dataframe these keyword arguments are used in the conversion to "json", "csv", "md", or "html". See Pandas Dataframe conversion methods (like
to_json()
) for more information.
See also:
- pandas.DataFrame.to_json documentation
- pandas.DataFrame.to_csv documentation
- pandas.DataFrame.to_html documentation
- pandas.DataFrame.to_markdown documentation
Example
1 2 3 4 5 6 7 8 9 10 11 |
|
log_video ¶
log_video(
filename: Union[str, IO],
name: Optional[str] = None,
overwrite: bool = False,
step: Optional[int] = None,
epoch: Optional[int] = None,
context: Optional[str] = None,
metadata: Optional[Dict[str, Any]] = None,
) -> Dict[str, Any]
Logs the video to Comet. Videos are displayed on the assets tab in Comet and support the following formats: MP4, MOV, WMV, and GIF.
Parameters:
filename
(str
) –The path to the video file.
name
(str
, default:None
) –A custom name can be provided to be displayed on the assets tab. If not provided, the filename from the file argument will be used if it is a path.
overwrite
(bool
, default:False
) –If another video with the same name exists, it will be overwritten if overwrite is set to True.
step
(int
, default:None
) –This is used to associate the video asset with a specific step.
epoch
(int
, default:None
) –Used to associate the asset to a specific epoch.
context
(str
, default:None
) –The current context (e.g., "train" or "test")
metadata
(dict
, default:None
) –Additional custom metadata can be associated with the logged video.
Example
1 2 3 4 5 6 |
|
register_model ¶
register_model(
model_name,
version=None,
workspace=None,
registry_name=None,
public=None,
description=None,
comment=None,
status=None,
tags=None,
stages=None,
)
Register an experiment model in the workspace registry.
Parameters:
model_name
(str
) –The name of the experiment model.
workspace
(str
, default:None
) –This argument is deprecated and ignored.
version
(str
, default:None
) –A proper semantic version string; defaults to "1.0.0".
registry_name
(str
, default:None
) –The name of the registered workspace model, if not provided the model_name will be used instead.
public
(bool
, default:None
) –If True, then the model will be publically viewable.
description
(str
, default:None
) –A textual description of the model.
comment
(str
, default:None
) –A textual comment about the model.
tags
(Any
, default:None
) –A list of textual tags such as ["tag1", "tag2"], etc.
stages
(Any
, default:None
) –Equivalent to tags, DEPRECATED with newer backend versions.
status
(str
, default:None
) –Allowed values are configured at the organization level.
Returns:
dict
–if successful, the dict will looks like this:
{"registryModelId": "ath6ho4eijaexeShahJ9sohQu", "registryModelItemId": "yoi5saes7ea2vooG2ush1uuwi"}
set_code ¶
set_code(code=None, filename=None)
Set the code for this experiment. Pass in either the code as a string, or provide filename.
Parameters:
code
(str
, default:None
) –The source code for this experiment
filename
(str
, default:None
) –The filename for this experiment
Example
1 2 3 4 5 6 7 |
|
set_command ¶
set_command(command_args_list)
Set the command-line (script and args) for this experiment.
Parameters:
command_args_list
(List[str]
) –Starting with name of script, and followed by arguments.
Example
1 2 3 4 5 6 |
|
set_end_time ¶
set_end_time(end_server_timestamp)
Set the end time of an experiment.
Parameters:
end_server_timestamp
(int
) –A timestamp in milliseconds
Example
1 2 3 4 5 6 |
|
Note
Time is in milliseconds. If the start time has not been set, it will be set to 1 second before the end time.
set_executable ¶
set_executable(executable)
Set the executable for this experiment.
Parameters:
executable
(str
) –The python executable.
Example
1 2 3 4 5 6 |
|
set_filename ¶
set_filename(filename)
Set the path and filename for this experiment.
Parameters:
filename
(str
) –The python path and filename.
Example
1 2 3 4 5 6 |
|
set_git_metadata ¶
set_git_metadata(user, root, branch, parent, origin)
Set the git metadata for this experiment.
Parameters:
user
(str
) –The name of the git user.
root
(str
) –The name of the git root.
branch
(str
) –The name of the git branch.
parent
(str
) –The name of the git parent.
origin
(str
) –The name of the git origin.
Example
1 2 3 4 5 6 |
|
set_git_patch ¶
set_git_patch(file_data)
Set the git patch for this experiment.
Parameters:
file_data
(str
) –the contents or filename of the git patch file
Example
1 2 3 4 5 6 |
|
set_gpu_static_info ¶
set_gpu_static_info(gpu_static_info)
Set the GPU static info for this experiment.
Parameters:
gpu_static_info
(list
) –list of dicts containing keys
gpuIndex
,name
,uuid
,totalMemory
, andpowerLimit
and their values.
Example
1 2 3 4 5 6 7 8 9 10 11 12 |
|
set_hostname ¶
set_hostname(hostname)
Set the hostname for this experiment.
Parameters:
hostname
(str
) –The hostname of the computer the experiment ran on.
Example
1 2 3 4 5 6 |
|
set_installed_packages ¶
set_installed_packages(installed_packages)
Set the installed Python packages for this experiment.
Parameters:
installed_packages
(List[str]
) –A list of the installed Python packages.
Example
1 2 3 4 5 6 |
|
set_ip ¶
set_ip(ip)
Set the internet protocol (IP) address for this experiment.
Parameters:
ip
(str
) –The internet protocol address.
Example
1 2 3 4 5 6 |
|
set_machine ¶
set_machine(machine)
Set the machine for this experiment.
Parameters:
machine
(str
) –The machine type.
Example
1 2 3 4 5 6 7 |
|
set_model_graph ¶
set_model_graph(graph)
Set the model graph for this experiment.
Parameters:
graph
(Any
) –A representation of the model graph
Example
1 2 3 4 5 6 |
|
set_name ¶
set_name(name)
Set a name for the experiment. Useful for filtering and searching on Comet.ml. Will shown by default under the Other
tab.
Parameters:
name
(str
) –A name for the experiment.
set_network_interface_ips ¶
set_network_interface_ips(network_interface_ips)
Set the network interface ips for this experiment.
Parameters:
network_interface_ips
(List[str]
) –Local network interfaces
Example
1 2 3 4 5 6 |
|
set_os ¶
set_os(os)
Set the OS for this experiment.
Parameters:
os
(str
) –The OS platform identifier.
Example
1 2 3 4 5 6 7 |
|
set_os_packages ¶
set_os_packages(os_packages)
Set the OS packages for this experiment.
Parameters:
os_packages
(List[str]
) –The OS package list
Example
1 2 3 4 5 6 |
|
set_os_release ¶
set_os_release(os_release)
Set the OS release for this experiment.
Parameters:
os_release
(str
) –The OS release.
Example
1 2 3 4 5 6 7 |
|
set_os_type ¶
set_os_type(os_type)
Set the OS type for this experiment.
Parameters:
os_type
(str
) –The OS type.
Example
1 2 3 4 5 6 |
|
set_pid ¶
set_pid(pid)
Set the process ID for this experiment.
Parameters:
pid
(str
) –The OS process ID
Example
1 2 3 4 5 6 |
|
set_processor ¶
set_processor(processor)
Set the processor for this experiment.
Parameters:
processor
(str
) –The processor name.
Example
1 2 3 4 5 6 7 |
|
set_python_version ¶
set_python_version(python_version)
Set the Python version for this experiment.
Parameters:
python_version
(str
) –The verbose Python version
Example
1 2 3 4 5 6 |
|
set_python_version_verbose ¶
set_python_version_verbose(python_version_verbose)
Set the Python version verbose for this experiment.
Parameters:
python_version_verbose
(str
) –The verbose Python version.
Example
1 2 3 4 5 6 |
|
set_start_time ¶
set_start_time(start_server_timestamp)
Set the start time of an experiment.
Parameters:
start_server_timestamp
(int
) –A timestamp in milliseconds.
Example
1 2 3 4 5 6 |
|
Note
Time is in milliseconds. If the end time has not been set it will automatically be set for 1 second after the start time.
set_state ¶
set_state(state: str)
Set current state of the experiment.
Parameters:
state
(str
) –String representing new experiment state. Must be either: 'running', 'finished' or 'crashed'
set_user ¶
set_user(user)
Set the user for this experiment.
Parameters:
user
(str
) –The OS username.
Example
1 2 3 4 5 6 |
|
to_json ¶
to_json(full=False)
The experiment data in JSON-like format.
Parameters:
full
(bool
, default:False
) –if True, get all experiment information.
Example
experiment.to_json()
Returns:
json
–Experiment data in json format, follows the format:
{'id': '073e272581ac48c283910a05e5495381', 'name': None, 'workspace': 'testuser', 'project_name': 'test-project-7515', 'archived': False, 'url': 'https://www.comet.com/testuser/test-project-7515/073e272581ac48c283910a05e54953801', 'duration_millis': 4785, 'start_server_timestamp': 1571318652586, 'end_server_timestamp': 7437457, 'optimization_id': None, }
update_status ¶
update_status()
Update the status for this experiment. Sends the keep-alive status for it in the UI. The return JSON dictionary contains the recommended interval to send subsequent update_status()
messages.
Returns:
dict
–Returns the following dictionary object:
{ 'isAliveBeatDurationMillis': 10000, 'gpuMonitorIntervalMillis': 60000, 'cpuMonitorIntervalMillis': 68000 }
Example
1 2 3 4 5 6 |
|