OpenPAI SDK
Перейти к файлу
yiyione 777ce897a2
Refine rest API request and error handle (#22)
* split v1 and v2

* add constants and errors

* refine and fix tests

* fix

* add pai errors

* update lib

* for a clear api folder structure (#24)

* set linebreak-style to false

* explicit query parameters in get methods (#25)

* Yiyi/update clients (#26)

* update

* update

* update vc client

* reset

Co-authored-by: yiyione <yiyi_one@foxmail.com>

* add group client (#27)

Co-authored-by: yiyione <yiyi_one@foxmail.com>

* change all client method names (#28)

Co-authored-by: yiyione <yiyi_one@foxmail.com>

* change method names and fix tests (#29)

* change all client method names

* fix tests

Co-authored-by: yiyione <yiyi_one@foxmail.com>

Co-authored-by: yiyione <yiyi_one@foxmail.com>
Co-authored-by: Yuqing Yang <yuqyang@microsoft.com>
Co-authored-by: Yi Yi <yiyi@microsoft.com>
2020-04-17 17:41:40 +08:00
docs Yuqing/new storage api (#9) 2020-03-09 14:32:33 +08:00
src Refine rest API request and error handle (#22) 2020-04-17 17:41:40 +08:00
tests Refine rest API request and error handle (#22) 2020-04-17 17:41:40 +08:00
.gitignore command line interface structure (#7) 2020-02-25 21:22:55 +08:00
.prettierrc js sdk (#2) 2020-01-16 17:23:46 +08:00
.travis.yml Update .travis.yml (#16) 2020-03-26 22:42:12 +08:00
CODE_OF_CONDUCT.md Initial CODE_OF_CONDUCT.md commit 2019-12-30 23:34:25 -08:00
LICENSE Initial LICENSE commit 2019-12-30 23:34:28 -08:00
README.md Fix broken links in README (#21) 2020-04-07 11:11:47 +08:00
SECURITY.md Initial SECURITY.md commit 2019-12-30 23:34:29 -08:00
package-lock.json Refine rest API request and error handle (#22) 2020-04-17 17:41:40 +08:00
package.json Refine rest API request and error handle (#22) 2020-04-17 17:41:40 +08:00
tsconfig.base.json Refine rest API request and error handle (#22) 2020-04-17 17:41:40 +08:00
tsconfig.build.json Refine rest API request and error handle (#22) 2020-04-17 17:41:40 +08:00
tsconfig.json Refine rest API request and error handle (#22) 2020-04-17 17:41:40 +08:00
tslint.json Refine rest API request and error handle (#22) 2020-04-17 17:41:40 +08:00

README.md

OpenPAI JS SDK

Build Status

The JavaScript SDK is designed to facilitate the developers of OpenPAI to offer user friendly experience.

The SDK mainly provides client side sharable functions such as RESTful API wrapping, error handling, storage accessing and processing of job protocol. Now the OpenPAI RESTful API is updating, please waiting for our stable release.

It could be used to support existing or future front-ends (e.g. Web Portal, VS Code extension, Command Line Interface, Jupyter Notebook extension, and 3rd party clients), and also could be used to simplify the design of kube runtime plugins, which are executed in init containers.

Now we are porting some of the functions from existing Python SDK and command line tool. The whole functionality of this SDK will be ready soon.

Installation

npm install --save microsoft/openpaisdk

Initialize the openPAIClient

const cluster: IPAICluster = {
    username: '<username>',
    password: '<password>',
    token: '<token>',
    rest_server_uri: '<The host>/rest-server'
};
const openPAIClient = new OpenPAIClient(cluster);

Installation of CLI tool

The SDK offers a command line interface (CLI) prefixed by pai. For end users that use CLI only, we provide an easy way to install it via pip and the Python package nodeenv.

pip install nodeenv
nodeenv myenv
source myenv/bin/activate # use `myenv/Scripts/activate` instead on Windows
npm i -g microsoft/openpaisdk

This installation commands will generate a virtual environment with latest node in the directory ./myenv, and install the CLI in it. Then user could use pai command by any of below methods

  • activate the virtual environment first
    myenv/Scripts/activate
    pai -h
    
  • use a absolute path to pai
    myenv/Scripts/pai -h
    
  • add myenv/Scripts to environment variable path

RESTful API

The SDK provides ease-of-use JavaScript and TypeScript wrapping of OpenPAI RESTful APIs.

Details are in rest-api.md.

Storage Operations

Multiple types of storages are supported by OpenPAI, however, the end user and developers should not be bothered by too much details of it. The SDK provides an abstract storage accessing methods to let users access the storages.

User could get the IStorageNode object for each cluster provisioned storage by

// get a storage object with its name
let storageDetail: IStorageDetail = await opanPAIClient.storage.getStorageByName(name)
let storageNode: IStorageNode = new StorageNode(storageDetail)

It would provide storage accessing methods (getinfo, listdir, makedir, upload, download, delete) and CLI storage operations.

Details are in storage.md.

Local Cluster Management

In some scenarios (e.g. cli or notebook extension), it is required to store the cluster information locally.

Unified error handling

The SDK will center the error handling, thus all front ends depending on it could share the same way to warn users.

Common job config processing

The interoperation of OpenPAI components depends on the job protocol, and there have been some common operations of it, such as validation, preprocessing before submission (e.g. embedding essential user information). The SDK will provide essential common operations for all the front ends.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.