Resource-Related SDKs
Prerequisites
- You have configured the Java SDK environment by following the instructions provided Overview.
- You have initialized the DLI Client by following the instructions provided in Initializing the DLI Client.
Uploading a Resource Package
You can use the APIs provided by DLI to upload resource packages. The following is an example. For details about the dependencies and complete sample code, see Overview.
1 2 3 4 5 6 |
def upload_resource(dli_client, kind, obs_jar_paths, group_name): try: dli_client.upload_resource(kind, obs_jar_paths, group_name) except DliException as e: print(e) return |
The following describes the request parameters. For details, see Overview.
- kind: resource package type. The options are as follows:
- jar: JAR file
- Pyfile: User Python file
- file: User file
- modelfile: User AI model file
- obs_jar_paths: OBS path of the resource package. The parameter format is {bucketName}.{obs domain name}/{jarPath}/{jarName}.
Example: "https://bucketname.obs.com/jarname.jar"
- group_name: Name of the group to which the resource package belongs
Querying All Resource Packages
You can use the API provided by DLI to query the list of uploaded resources. The example code is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 |
def list_resources(dli_client): try: resources = dli_client.list_resources() except DliException as e: print(e) return for resources_info in resources.package_resources: print('Package resource name:' + resources_info.resource_name) for group_resource in resources.group_resources: print('Group resource name:' + group_resource.group_name) |
For details about the dependencies and complete sample code, see Overview.
Querying a Specified Resource Package
def get_package_resource(dli_client, resource_name, group_name): try: pkg_resource = dli_client.get_package_resource(resource_name, group_name) print(pkg_resource) except DliException as e: print(e) return
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot