Home

Awesome

OpenPAI VS Code Client

Version Coverage Status

简体中文

OpenPAI VS Code Client is an extension to connect OpenPAI clusters, submit AI jobs, simulate jobs locally, manage files, and so on.

Connect to an OpenPAI cluster

Before using OpenPAI VS Code Client, follow below steps connecting to an OpenPAI cluster.

Basic login

Notice, the version of OpenPAI cluster must equal or greater than 0.8.0, and the authn_type of the cluster should be basic.

  1. Use shortcut key <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> to open command palette.

  2. Input and look for PAI: Add PAI Cluster as below.

    add cluster

  3. Press <kbd>Enter</kbd>, and input the host of an OpenPAI cluster. It can be domain name or IP Address. After that, press <kbd>Enter</kbd> again.

    add cluster host

  4. A configuration file is opened, and username and password fields are needed at least. Once it completes, click Finish button at right bottom corner. Notice, it won't be effect, if you save and close the file directly.

    add cluster configuration

If there are multiple OpenPAI clusters, you can follow above steps again to connect with them.

AAD login

Notice, the version of OpenPAI cluster must equal or greater than 0.14.0, and the authn_type of the cluster should be OIDC.

  1. Use shortcut key <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> to open command palette.

  2. Input and look for PAI: Add PAI Cluster as below.

    add cluster

  3. Press <kbd>Enter</kbd>, and input the host of an OpenPAI cluster. It can be domain name or IP Address. After that, press <kbd>Enter</kbd> again.

    add cluster host

  4. If the authn_type of the cluster is OIDC, a webside will be open and ask you to login, after that a configuration file is opened, and if your login was successful the username and token fields are auto filled, you can change it if needed. Once it completes, click Finish button at right bottom corner. Notice, it won't be effect, if you save and close the file directly.

    add cluster configuration

If there are multiple OpenPAI clusters, you can follow above steps again to connect with them.

Submit job

There is a tutorial for OpenPAI job submission, please refer to Submit job to OpenPAI. After added a cluster configuration, you can find the cluster in PAI CLUSTER EXPLORER pane as below.

pai cluster explorer

Submit V2 job (For OpenPAI v0.13.0 and above):

You can create a job v2 configuration and submit to OpenPAI as below steps.

  1. Create job config file:

    1. Double click Create Job Config... in OpenPAI cluster Explorer, and then specify file name and location to create a job configuration file (Make sure the value of protocol_version property in cluster configuration is '2').
    2. Right click python or cntk file in VSCode Explorer and select Create PAI Job Config V2, and then specify file name and location to create a job configuration file.
  2. Update job configuration as needed. If you are not familiar with this configuration file, learn from here.

  3. Right click on the created job v2 configuration file, then click on Submit Job to PAI Cluster. The client will upload files to OpenPAI and create a job. Once it's done, there is a notification at right bottom corner, you can click to open the job detail page.

    If there are multiple OpenPAI clusters, you need to choose one.

    This animation shows above steps. submit job

Submit V1 Job (deprecating, only for OpenPAI version under 0.13.0):

You can create a job configuration and submit to OpenPAI as below steps.

  1. Create job config file:

    1. Double click Create Job Config... in OpenPAI cluster Explorer, and then specify file name and location to create a job configuration file (Make sure the value of protocol_version property in cluster configuration is '1').
    2. Right click python or cntk file in VSCode Explorer and select Create PAI Job Config V1, and then specify file name and location to create a job configuration file.
  2. Update job configuration as needed. If you are not familiar with this configuration file, learn from here.

  3. Right click on the created job configuration file, then click on Submit Job to PAI Cluster. The client will upload files to OpenPAI and create a job. Once it's done, there is a notification at right bottom corner, you can click to open the job detail page.

    If there are multiple OpenPAI clusters, you need to choose one.

    This animation shows above steps. submit job

Local simulation

As it needs sometime to wait job starting in OpenPAI cluster, local simulation can help identifying and debugging most code, environment and configuration issues quickly.

Prerequisites

Docker MUST be installed to use local simulation.

Steps

  1. As submit a job, you can right click a configuration file to find local simulation.

  2. Click Simulate PAI Job Running, after a while below notification shows.

    simulate running

  3. you can click on Simulate first task in VS Code terminal to simulate directly, or Reveal in Explorer to view created docker files and start simulation manually.

This animation shows above steps. simulate job

Limitations

As local simulation is a close but still different environment with OpenPAI cluster, there are some issues cannot be found by simulation. Some examples,

Source code auto upload

Please refer to Auto Upload.

Reference

GUI

The client has two GUI parts. First is the PAI CLUSTER EXPLORER in explorer and used in above introduction. Second can be opened by the icon in activity bar.

activity bar

There are three parts in the side bar.

job list

Command Palette

NameDescription
PAI: Add PAI ClusterAdd a new OpenPAI cluster
PAI: Open WebsiteView OpenPAI cluster in browser
PAI: Submit Job to PAI ClusterSubmit an OpenPAI job
PAI: Create PAI Job Config FileCreate an OpenPAI configuration file
PAI: Simulate PAI Job RunningGenerate Docker file for local simulation

PAI Cluster Explorer

NameDescription
Open Web Portal...Browse to OpenPAI's web portal
List Jobs...Open PAI's job list page in VS Code
Create Job Config...Create an OpenPAI configuration file
Submit Job...Submit an OpenPAI job
Simulate Job Running...Generate Docker file for local simulation
Edit Configuration...Edit OpenPAI cluster configuration
Open HDFS...Open HDFS storage explorer of OpenPAI cluster

Settings

IDDescription
pai.job.upload.enabledWhether will upload files to codeDir of configuration
pai.job.upload.excludeExcluded files and folders for uploading
pai.job.upload.includeIncluded files and folders for uploading
pai.job.generateJobName.enabledWhether add a random suffix to job name when submitting
pai.job.jobList.recentJobsLengthThe number in Recent Submitted Jobs from VS Code
pai.job.jobList.allJobsPageSizeThe page size of the All Jobs list
pai.job.jobList.refreshIntervalThe refresh interval of job list (in seconds)
pai.hdfs.locationWhere HDFS storage will be shown

Developer Support

Getting started

  1. Install prerequisites:

    • latest Visual Studio Code
    • Node.js v10.0.0 or higher
    • yarn v1.17.3 or higher
  2. Install extension dependencies:

    • In the VS Code Extensions tab, search for RedHat YAML and install that extension
  3. Fork and clone this repository and go into the folder:

    git clone https://github.com/Microsoft/openpaivscode
    cd openpaivscode
    
  4. Install the dependencies:

    yarn install
    

Debug in vscode

Press F5 to launch debug window

Package to VSIX

yarn package

Issue and suggestions

Submit at GitHub

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.

License

MIT