Skip to content

Commit

Permalink
DOCS-2428: Merge autogen: bill,mltrain (#3038)
Browse files Browse the repository at this point in the history
Co-authored-by: Naomi Pentrel <[email protected]>
  • Loading branch information
andf-viam and npentrel authored Jun 26, 2024
1 parent ced4ac2 commit 2e0aead
Show file tree
Hide file tree
Showing 14 changed files with 296 additions and 251 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/sdk_protos_map.csv
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,11 @@ data_sync,FileUploadFromPath,file_upload_from_path,,
data_sync,StreamingDataCaptureUpload,streaming_data_capture_upload,,

## MLTraining
## TODO: Something wrong with parsing: submit_training_job in PySDK (??):
mltraining,SubmitTrainingJob,,,
mltraining,SubmitTrainingJob,submit_training_job,,
mltraining,GetTrainingJob,get_training_job,,
mltraining,ListTrainingJobs,list_training_jobs,,
mltraining,CancelTrainingJob,cancel_training_job,,
## Borked in Python: https://python.viam.dev/autoapi/viam/app/ml_training_client/index.html#viam.app.ml_training_client.MLTrainingClient.delete_completed_training_job
mltraining,DeleteCompletedTrainingJob,,,
mltraining,DeleteCompletedTrainingJob,delete_completed_training_job,,

## Robot
## Omitting some Flutter methods from now until we can determine what they do
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/update_sdk_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,6 @@
'viam.app.data_client.DataClient.configure_database_user', # unimplemented
'viam.app.data_client.DataClient.create_filter', # deprecated
'viam.app.data_client.DataClient.delete_tabular_data_by_filter', # deprecated
'viam.app.ml_training_client.MLTrainingClient.submit_training_job', # unimplemented
'viam.components.input.client.ControllerClient.reset_channel', # GUESS ?
'viam.robot.client.RobotClient.transform_point_cloud', # unimplemented
'viam.robot.client.RobotClient.get_component', # GUESS ?
Expand Down
4 changes: 2 additions & 2 deletions docs/appendix/apis/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ The [data client API](/appendix/apis/data-client/) supports the following method

The ML training API allows you to get information about and cancel ML training jobs taking place on the [Viam app](https://app.viam.com):

{{< readfile "/static/include/services/apis/ml-training-client.md" >}}
{{< readfile "/static/include/app/apis/generated/mltraining-table.md" >}}

### Billing client API

The [billing client API](/appendix/apis/billing-client/) supports the following methods to retrieve billing information from the [Viam app](https://app.viam.com):

{{< readfile "/static/include/services/apis/billing-client.md" >}}
{{< readfile "/static/include/app/apis/generated/billing-table.md" >}}

## Component APIs

Expand Down
105 changes: 2 additions & 103 deletions docs/appendix/apis/billing-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,107 +71,6 @@ Once you have instantiated a `BillingClient`, you can run [API methods](#api) ag

The billing client API supports the following methods:

{{< readfile "/static/include/services/apis/billing-client.md" >}}
{{< readfile "/static/include/app/apis/generated/billing-table.md" >}}

### GetCurrentMonthUsage

Access data usage information for the current month for a given organization.
You can also find your usage data on the [**Payment and billing** page](/billing/).

{{< tabs >}}
{{% tab name="Python" %}}

**Parameters:**

- org_id ([str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)): the ID of the organization to request usage data for

**Returns:**

- ([viam.proto.app.billing.GetCurrentMonthUsageResponse](https://python.viam.dev/autoapi/viam/proto/app/billing/index.html#viam.proto.app.billing.GetCurrentMonthUsageResponse)): Current month usage information

```python {class="line-numbers linkable-line-numbers"}
usage = await viam_client.billing_client.get_current_month_usage("<ORG-ID>")
```

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/app/billing_client/index.html#viam.app.billing_client.BillingClient.get_current_month_usage).

{{% /tab %}}
{{< /tabs >}}

### GetInvoicePdf

Access invoice PDF data and optionally save it to a provided file path.
You can also find your invoices on the [**Payment and billing** page](/billing/).

{{< tabs >}}
{{% tab name="Python" %}}

**Parameters:**

- `invoice_id` ([str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)): the ID of the invoice being requested
- `org_id` ([str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)): the ID of the org to request data from
- `dest` ([str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)): filepath to save the invoice to

**Returns:**

- None.

```python {class="line-numbers linkable-line-numbers"}
await viam_client.billing_client.get_invoice_pdf(
"<INVOICE-ID>", "<ORG-ID>", "<FILENAME>")
```

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/app/billing_client/index.html#viam.app.billing_client.BillingClient.get_invoice_pdf).

{{% /tab %}}
{{< /tabs >}}

### GetInvoicesSummary

Access total outstanding balance plus invoice summaries for a given org.

{{< tabs >}}
{{% tab name="Python" %}}

**Parameters:**

- org_id ([str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)): the ID of the org to request data for

**Returns:**

- ([viam.proto.app.billing.GetInvoicesSummaryResponse](https://python.viam.dev/autoapi/viam/proto/app/billing/index.html#viam.proto.app.billing.GetInvoicesSummaryResponse)): Summary of org invoices

```python {class="line-numbers linkable-line-numbers"}
summary = await viam_client.billing_client.get_invoices_summary("<ORG-ID>")
```

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/app/billing_client/index.html#viam.app.billing_client.BillingClient.get_invoices_summary).

{{% /tab %}}
{{< /tabs >}}

### GetOrgBillingInformation

Access billing information (payment method, billing tier, etc.) for a given org.
You can also find this information on the [**Payment and billing** page](/billing/).

{{< tabs >}}
{{% tab name="Python" %}}

**Parameters:**

- org_id (str): the ID of the org to request data for

**Returns:**

- ([viam.proto.app.billing.GetOrgBillingInformationResponse](https://python.viam.dev/autoapi/viam/proto/app/billing/index.html#viam.proto.app.billing.GetOrgBillingInformationResponse)): The org billing information

```python {class="line-numbers linkable-line-numbers"}
information = await viam_client.billing_client.get_org_billing_information(
"<ORG-ID>")
```

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/app/billing_client/index.html#viam.app.billing_client.BillingClient.get_org_billing_information).

{{% /tab %}}
{{< /tabs >}}
{{< readfile "/static/include/app/apis/generated/billing.md" >}}
143 changes: 2 additions & 141 deletions docs/appendix/apis/ml-training-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,145 +67,6 @@ Once you have instantiated an `MLTrainingClient`, you can run the following [API

The ML training client API supports the following methods:

{{< readfile "/static/include/services/apis/ml-training-client.md" >}}
{{< readfile "/static/include/app/apis/generated/mltraining-table.md" >}}

### GetTrainingJob

Get training job metadata.

{{< tabs >}}
{{% tab name="Python" %}}

**Parameters:**

- `id` [(str)](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str): ID of the training job you wish to get metadata from. Retrieve this value with [`ListTrainingJobs()`](#listtrainingjobs).

**Returns**:

- [(TrainingJobMetadata)](https://python.viam.dev/autoapi/viam/proto/app/mltraining/index.html#viam.proto.app.mltraining.TrainingJobMetadata): Training job metadata, including status, last modified timestamp, id, and more.

```python {class="line-numbers linkable-line-numbers"}
job_metadata = await ml_training_client.get_training_job(
id="INSERT YOUR JOB ID")
```

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/app/ml_training_client/index.html#viam.app.ml_training_client.MLTrainingClient.get_training_job).

{{% /tab %}}
{{< /tabs >}}

### ListTrainingJobs

Get training job metadata for all jobs within an organization.

{{< tabs >}}
{{% tab name="Python" %}}

**Parameters:**

- `org_id` [(str)](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str): The ID of your organization to request training job metadata from. Retrieve this value with the fleet management API's [`ListOrganizations()`](/appendix/apis/fleet/#listorganizations).
- `training_status` [(Optional[TrainingStatus.ValueType])](https://python.viam.dev/autoapi/viam/gen/app/mltraining/v1/ml_training_pb2/index.html#viam.gen.app.mltraining.v1.ml_training_pb2.TrainingStatus): The status of training jobs you want to filter the list by. If you leave this unspecified, all training jobs for your organization are returned.

**Returns**:

- [(List[TrainingJobMetadata])](https://python.viam.dev/autoapi/viam/proto/app/mltraining/index.html#viam.proto.app.mltraining.TrainingJobMetadata): A list of training job metadata, including status, last modified timestamp, id, and more.

```python {class="line-numbers linkable-line-numbers"}
jobs_metadata = await ml_training_client.list_training_jobs(
org_id="INSERT YOUR ORG ID")

first_job_id = jobs_metadata[1].id
```

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/app/ml_training_client/index.html#viam.app.ml_training_client.MLTrainingClient.list_training_jobs).

{{% /tab %}}
{{< /tabs >}}

### SubmitTrainingJob

Submit a training job.

{{< tabs >}}
{{% tab name="Python" %}}

**Parameters:**

- `org_id` ([str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)) (required): The ID of the organization to submit the training job to. To retrieve this, expand your organization's dropdown in the top right corner of the [Viam app](https://app.viam.com/), select **Settings**, and copy **Organization ID**.
- `dataset_id` ([str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)) (required): The ID of the dataset to train the ML model on. To retrieve this, navigate to your dataset's page in the [Viam app](https://app.viam.com/data/datasets), click **...** in the left-hand menu, and click **Copy dataset ID**.
- `model_name` ([str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)) (required): The name of the ML model you wish to train.
- `model_version` ([str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)) (required): The version of the ML model you're training. This string must be unique from any previous versions you've set.
- `model_type` ([ModelType.ValueType](https://python.viam.dev/autoapi/viam/gen/app/mltraining/v1/ml_training_pb2/index.html#viam.gen.app.mltraining.v1.ml_training_pb2.ModelType)) (required): The type of the ML model. Options: `ModelType.MODEL_TYPE_SINGLE_LABEL_CLASSIFICATION`, `ModelType.MODEL_TYPE_MULTI_LABEL_CLASSIFICATION`, `ModelType.MODEL_TYPE_OBJECT_DETECTION`.
- `tags` ([List(str)](https://docs.python.org/3/library/stdtypes.html#typesseq-list)) (required): The labels to train on.

**Returns:**

- ([str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)): The ID of the training job created.

```python {class="line-numbers linkable-line-numbers"}
job_id = await ml_training_client.submit_training_job(
"3988fd7d-b1c0-4f36-9842-0c666f374d3c",
"66491a0666a6c8aa4a33e43e",
"your-model-name",
"1",
"ModelType.MODEL_TYPE_SINGLE_LABEL_CLASSIFICATION",
tags)
```

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/app/ml_training_client/index.html#viam.app.ml_training_client.MLTrainingClient.submit_training_job).

{{% /tab %}}
{{% tab name="Flutter" %}}

**Parameters:**

- `datasetId` [(String)](https://api.flutter.dev/flutter/dart-core/String-class.html) (required): The ID of the dataset to train the ML model on. To retrieve this, navigate to your dataset's page in the [Viam app](https://app.viam.com/data/datasets), click **...** in the left-hand menu, and click **Copy dataset ID**.
- `modelName` [(String)](https://api.flutter.dev/flutter/dart-core/String-class.html) (required): The name of the ML model to train.
- `modelType` [(ModelType)](https://flutter.viam.dev/viam_protos.app.ml_training/ModelType-class.html) (required): The type of the ML model. Options: `MODEL_TYPE_SINGLE_LABEL_CLASSIFICATION`, `MODEL_TYPE_MULTI_LABEL_CLASSIFICATION`, or `MODEL_TYPE_OBJECT_DETECTION`.
- `modelVersion` [(String)](https://api.flutter.dev/flutter/dart-core/String-class.html) (required): The version of the ML model you're training. This string must be unique from any previous versions you've set.
- `organizationId` [(String)](https://api.flutter.dev/flutter/dart-core/String-class.html) (required): The ID of the organization to submit the training job to. To retrieve this, expand your organization's dropdown in the top right corner of the [Viam app](https://app.viam.com/), select **Settings**, and copy **Organization ID**.
- `tags` [(List)](https://api.flutter.dev/flutter/dart-core/List-class.html)<[String](https://api.flutter.dev/flutter/dart-core/String-class.html)> (required): The labels to train on.

**Returns:**

- [(String)](https://api.flutter.dev/flutter/dart-core/String-class.html) (required): The ID of the training job created.

```dart {class="line-numbers linkable-line-numbers"}
final tags = <String>['A', 'B', 'C']; // Creates list of tags.
String jobID = ml_training.submitTrainingJob("66491a0666a6c8aa4a33e43e", "your-model-name", "MODEL_TYPE_SINGLE_LABEL_CLASSIFICATION", "1", "3988fd7d-b1c0-4f36-9842-0c666f374d3c", tags);
```

For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_protos.app.ml_training/MLTrainingServiceClient/submitTrainingJob.html).

{{% /tab %}}
{{< /tabs >}}

### CancelTrainingJob

Cancel the specified training job.

{{< tabs >}}
{{% tab name="Python" %}}

**Parameters:**

- `id` [(str)](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str): ID of the training job you wish to get metadata from. Retrieve this value with [`ListTrainingJobs()`](#listtrainingjobs).

**Returns**:

- None

**Raises**:

- `GRPCError`: If no training job exists with the given ID or cancellation was otherwise unsuccessful.

```python {class="line-numbers linkable-line-numbers"}
await ml_training_client.cancel_training_job(
id="INSERT YOUR JOB ID")
```

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/app/ml_training_client/index.html#viam.app.ml_training_client.MLTrainingClient.cancel_training_job).

{{% /tab %}}
{{< /tabs >}}
{{< readfile "/static/include/app/apis/generated/mltraining.md" >}}
7 changes: 7 additions & 0 deletions static/include/app/apis/generated/billing-table.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- prettier-ignore -->
| Method Name | Description |
| ----------- | ----------- |
| [`GetCurrentMonthUsage`](/appendix/apis/billing-client/#getcurrentmonthusage) | Access data usage information for the current month for a given organization. |
| [`GetOrgBillingInformation`](/appendix/apis/billing-client/#getorgbillinginformation) | Access billing information (payment method, billing tier, etc.) for a given org. |
| [`GetInvoicesSummary`](/appendix/apis/billing-client/#getinvoicessummary) | Access total outstanding balance plus invoice summaries for a given org. |
| [`GetInvoicePdf`](/appendix/apis/billing-client/#getinvoicepdf) | Access invoice PDF data and optionally save it to a provided file path. |
Loading

0 comments on commit 2e0aead

Please sign in to comment.