Metadata-Version: 2.4
Name: ngcsdk
Version: 4.18.0
Summary: NVIDIA GPU Cloud SDK
Project-URL: Documentation, https://docs.ngc.nvidia.com/sdk/
Project-URL: Homepage, https://ngc.nvidia.com/
Author: NVIDIA CORPORATION
License: Apache-2.0
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Requires-Dist: aiofiles>=23.2.1
Requires-Dist: aiohttp>=3.10.11
Requires-Dist: boto3>=1.20.5
Requires-Dist: botocore>=1.37
Requires-Dist: certifi>=2024.7.4
Requires-Dist: cryptography>=43.0.1
Requires-Dist: docker<8,>=6
Requires-Dist: isodate>=0.6
Requires-Dist: packaging>=24
Requires-Dist: polling2>=0.5
Requires-Dist: prettytable>3
Requires-Dist: psutil>=5.8
Requires-Dist: python-dateutil>=2.8.2
Requires-Dist: requests-toolbelt>=1
Requires-Dist: requests>=2.31
Requires-Dist: rich>=12.6
Requires-Dist: shortuuid>=1.0.11
Requires-Dist: urllib3<3,>=1.26
Requires-Dist: validators>=0.21
Provides-Extra: datamover
Requires-Dist: google-api-core>=2.2.2; extra == 'datamover'
Requires-Dist: grpcio>=1.71; extra == 'datamover'
Requires-Dist: protobuf>=4.21.1; extra == 'datamover'
Provides-Extra: telemetry
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc<2,>=1.20; extra == 'telemetry'
Requires-Dist: opentelemetry-instrumentation<1,>=0.41b0; extra == 'telemetry'
Requires-Dist: opentelemetry-sdk==1.20; extra == 'telemetry'
Description-Content-Type: text/markdown

# NGC-SDK
The NVIDIA NGC software development kit to interact and develop Python utilities and applications to integrate with the NVIDIA GPU Cloud.

## Prerequisites

    Python version >= 3.9

## Install from pypi

Install the package from pypi.org by running the following command:

`pip install ngcsdk`

This project will download and install additional third-party open source software projects. Review the license terms of these open source projects before use.

### Extras

Some features require additional dependencies, which are optional unless you need gRPC dataset upload or enhanced telemetry.

To install these extras, use:

`pip install ngcsdk[telemetry,datamover]`

After installing the SDK, the first step is to create and configure the client.

## Creating and configuring NGC SDK client

To set the configuration, run the following functions.

Tip

This needs an API key. For information about generating an API key, refer to the setup, https://ngc.nvidia.com/setup.

```python
from ngcsdk import Client

clt = Client()

clt.configure(api_key='****NkMQ', org_name='nvidia', team_name='no-team', ace_name='no-ace')
Validating configuration...
Successfully validated configuration.

clt.current_config()
[{'key': 'apikey', 'value': '****NkMQ', 'source': 'user settings'},
 {'key': 'format_type', 'value': 'ascii', 'source': 'user settings'},
 {'key': 'org', 'value': 'nvidia', 'source': 'user settings'},
 {'key': 'team', 'value': 'no-team', 'source': 'user settings'},
 {'key': 'ace', 'value': 'no-ace', 'source': 'user settings'}]
```

## Debugging

Configure debug logging using Python's logging utility.

```python
import logging

from ngcsdk import Client

logger = logging.getLogger()

logger.setLevel(logging.DEBUG)

clt = Client()

ace = clt.basecommand.aces.info("nv-us-west-2")
DEBUG:ngcbase.api.connection:Requesting URL (GET): https://api.stg.ngc.nvidia.com/v2/org/nvidia/aces/ceph-sjc-4-dev
    payload: None
    params: None
DEBUG:ngcbase.api.authentication:Retrieving API Key Token from cache....
DEBUG:ngcbase.api.authentication:Token in use: ****hPWE
DEBUG:ngcbase.api.authentication:Expiration time of token: '2024-03-07 16:36:03.849188'
DEBUG:ngcbase.api.authentication:Fetched token from the cache. Expires 2024-03-07 16:36:03.849188
DEBUG:ngcbase.api.utils:Headers:
DEBUG:ngcbase.api.utils:{'Content-Type': 'application/json', ...}
DEBUG:ngcbase.api.connection:Response status: 200 - Reason: OK
DEBUG:ngcbase.api.connection:Time taken to process URL: https://api.stg.ngc.nvidia.com/v2/org/nvidia/aces/ceph-sjc-4-dev: 0.34587s
DEBUG:ngcbase.api.connection:Response is: {"requestStatus":{"statusCode":"SUCCESS"}, ...}
```

For more information on how to configure logging, see Python's official tutorial on logging.

## Output

Methods return either objects or JSON. Objects can be inspected and converted to a python dictionary or JSON format.

```python
from ngcsdk import Client

clt = Client()

ace = clt.basecommand.aces.info("nv-us-west-2")

help(ace)
Help on Ace in module ngccli.data.api.Ace object:

class Ace(builtins.object)
 |  Ace(propDict=None)
 |
 |  ACE is a collection of nodes that can run jobs
 |
 |  Methods defined here:
 |
 |  __init__(self, propDict=None)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  isValid(self)
 |
 |  toDict(self)
 |
 |  toJSON(self, pretty=False)

ace.toDict()
{'allowExposedPort': False, ...}

ace.toJSON()
'{"allowExposedPort": false, ...}

aces = clt.basecommand.aces.list()

help(aces)
Help on chain object:

class chain(builtins.object)
 |  chain(*iterables) --> chain object
 |
 |  Return a chain object whose .__next__() method returns elements from the
 |  first iterable until it is exhausted, then elements from the next
 |  iterable, until all of the iterables are exhausted.
 |
 |  Methods defined here:
 |
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |
 |  __iter__(self, /)
 |      Implement iter(self).
 |
 |  __next__(self, /)
 |      Implement next(self).

[ace.name for ace in aces]
['ac-auth-debug-ace', ....]
```
