NGC Python SDK
Configuring NGC SDK
The first time you use NGC SDK after installing it, you must set your config. To set your config, run the following commands. You will need your API key, which can be obtained from (https://ngc.nvidia.com).
from ngcsdk import Client
client = Client()
client.configure(api_key="<YOUR-API-KEY>", org_name="<ORG-NAME>", team_name="<TEAM-NAME>", ace_name="<ACE-NAME>")
CLI Output Format
The following are examples of the CLI output format - ascii, csv, or json - in response to the ngc user who command.
ascii
>>> client.current_config()
[
{'key': 'apikey', 'value': '**************************************************************************************ABCD', 'source': 'global argument'},
{'key': 'format_type', 'value': 'json', 'source': 'global argument'},
{'key': 'org', 'value': 'org-name', 'source': 'global argument'}
]
>>> client.organization.user.who().toJSON()
'{"requestStatus": {"requestId": "12345678-1234-1234-1234-1234567890",
"statusCode": "SUCCESS"},
"user": {"clientId": "client-id",
"createdDate": "2022-02-23T18:01:30.000Z",
"email": "jsmith@example.com",
"firstLoginDate": "2022-02-23T18:01:31.000Z",
"hasBetaAccess": false,
"hasSignedBioNeMoEULA": false,
"hasSignedContainerPublishingEULA": false,
"hasSignedCuOptEULA": false,
"hasSignedEULA": true,
"hasSignedEgxEULA": false,
"hasSignedFleetCommandEULA": false,
"hasSignedLlmEULA": false,
"hasSignedNVAIEEULA": false,
"hasSignedNvidiaEULA": false,
"hasSignedOmniverseEULA": false,
"hasSignedPrivacyPolicy": true,
"hasSignedThirdPartyRegistryShareEULA": false,
"hasSubscribedToEmail": false,
"id": 123,
"idpType": "IDP-TYPE",
"isActive": false,
"isDeleted": false,
"isSAML": false,
"lastLoginDate": "2022-02-23T18:01:31.000Z",
"name": "basic_test_Acct",
. . . . .
}
}'
Setting Your Configuration
NGC SDK configuration determines which DGX resources you can use to run jobs. It also determines which container registry space within your organization you can access.
When you configured NGC SDK for the first time, you selected the default organization to associate with your user name. If you will be using the resources associated with your organization, then no other action is necessary.
However, to use resources and container registry spaces associated with other organizations, teams, or aces of which you are a member, you must change your configuration accordingly.
Format:
client.configure(api_key="<YOUR-API-KEY>", org_name="<ORG-NAME>", team_name="<TEAM-NAME>", ace_name="<ACE-NAME>")
The organization name must be specified for all configurations.
Using NGC SDK
NGC SDK has methods in various modules. Here is a list of some of them:
client.organization
client.registry