Create a model for a URL or Dataset ID
gradient models create \
--name "New Model" \
--modelType "Tensorflow" \
--datasetRef "dsj1g16f1z67jai"
curl -X POST 'https://api.paperspace.io/mlModels/createModelV2' \
-H 'x-api-key: d44808a2785d6a...' \
-H 'Content-Type: application/json' \
--data-raw '{
"name": "New Model",
"datasetRef": "dsj1g16f1z67jai",
"modelType": "Tensorflow"
}'
from gradient import ModelsClient
api_key='d44808a2785d6a...'
models_client = ModelsClient(api_key)
print(models_client.create(
name='New Model',
dataset_ref='dsj1g16f1z67jai',
model_type='Tensorflow'
))
Name | Type | Attributes | Description |
---|---|---|---|
--name |
string | required | Model name |
--modelType |
string | required | Model type: Tensorflow , ONNX , Custom |
--datasetRef |
string | required | Dataset ref to associate model with |
--projectId |
string | optional | ID of a project |
--modelSummary |
string | optional | Model summary |
--notes |
string | optional | Additional notes |
--tag |
string | optional | One or many tags that you want to add |
--tags |
string | optional | Tags separated by comma |
--apiKey |
string | optional | API key to use this time only |
--optionsFile |
string | optional | Path to YAML with predefined options |
--createOptionsFile |
string | optional | Generate template options file |
Model created with ID: moseiu8dirfro8k
{
"id": "moseiu8dirfro8k",
"projectId": null,
"updatedByUserId": "ubx9ce8k",
"updatedByUserEmail": "[email protected]",
"accessorHandles": null,
"modelType": "Tensorflow",
"name": "New Model",
"tag": null,
"summary": null,
"detail": null,
"params": null,
"url": null,
"notes": null,
"isDeleted": false,
"isPublic": false,
"dtCreated": "2022-03-22T01:41:44.850Z",
"dtModified": "2022-03-22T01:41:44.850Z",
"dtUploaded": null,
"dtDeleted": null,
"modelPath": null,
"deploymentState": null,
"tags": null,
"datasetId": null,
"datasetVersion": null,
"datasetRef": "dsj1g16f1z67jai"
}
moseiu8dirfro8k
Show model details
gradient models details \
--id "moseiu8dirfro8k"
curl -X GET 'https://api.paperspace.io/mlModels/getModelList/' \
-H 'x-api-key: d44808a2785d6a...' \
-H 'Content-Type: application/json' \
--data-raw '{
"filter": {
"where": {
"and": [
{
"id": "moseiu8dirfro8k"
}
]
}
}
}'
from gradient import ModelsClient
api_key='d44808a2785d6a...'
models_client = ModelsClient(api_key)
print(models_client.get(
model_id='moseiu8dirfro8k'
))
Name | Type | Attributes | Description |
---|---|---|---|
--id |
string | required | Model ID |
--apiKey |
string | optional | API key to use this time only |
--optionsFile |
string | optional | Path to YAML with predefined options |
--createOptionsFile |
string | optional | Generate template options file |
+------------------+-----------------+
| ID | moseiu8dirfro8k |
+------------------+-----------------+
| Name | New Model |
| Project ID | None |
| Model Type | Tensorflow |
| URL | None |
| Deployment State | None |
| Tags | |
+------------------+-----------------+
{
"modelList": [
{
"id": "moseiu8dirfro8k",
"projectId": null,
"updatedByUserId": "ubx9ce8k",
"updatedByUserEmail": "[email protected]",
"accessorHandles": null,
"modelType": "Tensorflow",
"name": "New Model",
"tag": null,
"summary": null,
"detail": null,
"params": null,
"url": null,
"notes": null,
"isDeleted": false,
"isPublic": false,
"dtCreated": "2022-03-22T01:41:44.850Z",
"dtModified": "2022-03-22T01:41:44.850Z",
"dtUploaded": null,
"dtDeleted": null,
"modelPath": null,
"deploymentState": null,
"tags": null,
"datasetVersionId": null,
"datasetId": null,
"datasetVersion": null,
"datasetRef": null
}
],
"total": 5,
"displayTotal": 1
}
Model(
(id = "moseiu8dirfro8k"),
(name = "New Model"),
(project_id = None),
(cluster_id = None),
(tags = []),
(model_type = "Tensorflow"),
(url = None),
(model_path = None),
(deployment_state = None),
(summary = None),
(detail = None),
(notes = None),
(dataset_ref = None)
);
List models with optional filtering
gradient models list
curl -X GET 'https://api.paperspace.io/mlModels/getModelList/' \
-H 'x-api-key: d44808a2785d6a...'
from gradient import ModelsClient
api_key='d44808a2785d6a...'
models_client = ModelsClient(api_key)
print(models_client.list())
Name | Type | Attributes | Description |
---|---|---|---|
--projectId |
string | optional | Filter by project ID |
--tag |
string | optional | Filter by tag |
--apiKey |
string | optional | API key to use this time only |
--optionsFile |
string | optional | Path to YAML with predefined options |
--createOptionsFile |
string | optional | Generate template options file |
+-----------+-----------------+------------+------------+
| Name | ID | Model Type | Project ID |
+-----------+-----------------+------------+------------+
| New Model | moseiu8dirfro8k | Tensorflow | None |
+-----------+-----------------+------------+------------+
{
"modelList": [
{
"id": "moseiu8dirfro8k",
"projectId": null,
"updatedByUserId": "ubx9ce8k",
"updatedByUserEmail": "[email protected]",
"accessorHandles": null,
"modelType": "Tensorflow",
"name": "New Model",
"tag": null,
"summary": null,
"detail": null,
"params": null,
"url": null,
"notes": null,
"isDeleted": false,
"isPublic": false,
"dtCreated": "2022-03-22T01:41:44.850Z",
"dtModified": "2022-03-22T01:41:44.850Z",
"dtUploaded": null,
"dtDeleted": null,
"modelPath": null,
"deploymentState": null,
"tags": null,
"datasetVersionId": null,
"datasetId": null,
"datasetVersion": null,
"datasetRef": null
}
],
"total": 1,
"displayTotal": 1
}
[
Model(
(id = "moseiu8dirfro8k"),
(name = "New Model"),
(project_id = None),
(cluster_id = None),
(tags = []),
(model_type = "Tensorflow"),
(url = None),
(model_path = None),
(deployment_state = None),
(summary = None),
(detail = None),
(notes = None),
(dataset_ref = None)
),
];
Download model
gradient models download \
--id "moseiu8dirfro8k" \
--destinationDir "./"
curl -X GET 'https://api.paperspace.io/mlModels/listFiles/' \
-H 'x-api-key: d44808a2785d6a...' \
-H 'Content-Type: application/json' \
--data-raw '{
"id": "moseiu8dirfro8k",
"links": "True"
}'
from gradient import ModelsClient
api_key='d44808a2785d6a...'
models_client = ModelsClient(api_key)
print(models_client.get_model_files(
model_id='moseiu8dirfro8k',
links=True
))
Name | Type | Attributes | Description |
---|---|---|---|
--id |
string | required | Model ID |
--destinationDir |
string | required | Destination directory |
--apiKey |
string | optional | API key to use this time only |
--optionsFile |
string | optional | Path to YAML with predefined options |
--createOptionsFile |
string | optional | Generate template options file |
Downloading: data.txt
[
{
file: "data.txt",
url: "https://osg-ny2.paperspace.io/tewr3st2z/tewr3st2z/datasets/dsj1g16f1z67jai/versions/xbreynt/data/data.txt?AWSAccessKeyId=6P0NXXIKSB49ZW7ZXESL&Expires=1647944273&Signature=h6MrW%2B2WJuA%2FqE3MyAg9Qxpq4HQ%3D&response-content-disposition=attachment%3Bfilename%3D%22data.txt%22",
},
];
[
ModelFile(
(file = "data.txt"),
(url =
"https://osg-ny2.paperspace.io/tewr3st2z/tewr3st2z/datasets/dsj1g16f1z67jai/versions/xbreynt/data/data.txt?AWSAccessKeyId=6P0NXXIKSB49ZW7ZXESL&Expires=1647944439&Signature=Ji%2Fsc0tJYuGGMcgxvQFtRnS4Wio%3D&response-content-disposition=attachment%3Bfilename%3D%22data.txt%22"),
(size = None)
),
];
Upload a model file or directory
gradient models upload fashion-mnist.onnx \
--name "New Model" \
--modelType "ONNX"
This command is not available via CURL.
from gradient import ModelsClient
api_key='d44808a2785d6a...'
models_client = ModelsClient(api_key)
print(models_client.upload(
path='./fashion-mnist.onnx',
name='New Model',
model_type='ONNX'
))
Name | Type | Attributes | Description |
---|---|---|---|
--name |
string | required | Model name |
--modelType |
string | required | Model type: Tensorflow , ONNX , Custom |
--projectId |
string | optional | ID of a project |
--clusterID |
string | optional | ID of a cluster |
--modelSummary |
string | optional | Model summary |
--notes |
string | optional | Additional notes |
--tag |
string | optional | One or many tags that you want to add |
--tags |
string | optional | Tags separated by comma |
--apiKey |
string | optional | API key to use this time only |
--optionsFile |
string | optional | Path to YAML with predefined options |
--createOptionsFile |
string | optional | Generate template options file |
100% (408542 of 408542) |#####################################################################################################################| Elapsed Time: 0:00:00 Time: 0:00:00
Model uploaded with ID: moc0ackf1ivmmy
This command is not available via CURL.
moc0ackf1ivmmy
Delete a model
gradient models delete \
--id "moseiu8dirfro8k"
curl -X POST 'https://api.paperspace.io/mlModels/deleteModel/' \
-H 'x-api-key: d44808a2785d6a...' \
-H 'Content-Type: application/json' \
--data-raw ' {
"id": "moseiu8dirfro8k"
}'
from gradient import ModelsClient
api_key='d44808a2785d6a...'
models_client = ModelsClient(api_key)
print(models_client.delete(
model_id='moseiu8dirfro8k'
))
Name | Type | Attributes | Description |
---|---|---|---|
--id |
string | required | Model ID |
--apiKey |
string | optional | API key to use this time only |
--optionsFile |
string | optional | Path to YAML with predefined options |
--createOptionsFile |
string | optional | Generate template options file |
Add tags to ml model
gradient models tags add \
--id "moseiu8dirfro8k" \
--tag "import202203"
curl -X PUT 'https://api.paperspace.io/entityTags/updateTags' \
-H 'x-api-key: d44808a2785d6a...' \
-H 'Content-Type: application/json' \
--data-raw '{
"entity": "mlModel",
"entityId": "moseiu8dirfro8k",
"tags": [
"import202203"
]
}'
from gradient import ModelsClient
api_key='d44808a2785d6a...'
models_client = ModelsClient(api_key)
print(models_client.add_tags(
entity_id='moseiu8dirfro8k',
tags=['import202203']
))
Name | Type | Attributes | Description |
---|---|---|---|
--id |
string | required | Model ID |
--tag |
string | optional | One or more tags that you want to add to ml model |
--tags |
string | optional | Separated by comma tags that you want to add to ml model |
--apiKey |
string | optional | API key to use this time only |
--optionsFile |
string | optional | Path to YAML with predefined options |
--createOptionsFile |
string | optional | Generate template options file |
Tags added to ml model
[
{
"tagId": 680,
"entity": "mlModel",
"entityId": 32023,
"dtCreated": "2022-03-22T02:37:43.788Z",
"dtDeleted": null,
"userId": 750386,
"id": 7550,
"entity_id": 32023,
"tag": {
"name": "import202203",
"dtCreated": "2022-03-15T01:29:39.877Z",
"id": 680
}
}
]
None
Remove tags from ml model
gradient models tags remove \
--id "moseiu8dirfro8k" \
--tag "import202203"
curl -X PUT 'https://api.paperspace.io/entityTags/updateTags' \
-H 'x-api-key: d44808a2785d6a...' \
-H 'Content-Type: application/json' \
--data-raw '{
"entity": "mlModel",
"entityId": "moseiu8dirfro8k",
"tags": []
}'
from gradient import ModelsClient
api_key='d44808a2785d6a...'
models_client = ModelsClient(api_key)
print(models_client.remove_tags(
entity_id='moseiu8dirfro8k',
tags=['import202203']
))
Name | Type | Attributes | Description |
---|---|---|---|
--id |
string | required | Model ID |
--tag |
string | optional | One or more tags that you want to add to ml model |
--tags |
string | optional | Separated by comma tags that you want to add to ml model |
--apiKey |
string | optional | API key to use this time only |
--optionsFile |
string | optional | Path to YAML with predefined options |
--createOptionsFile |
string | optional | Generate template options file |