Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Utilize job protocol in market item #49

Merged
merged 43 commits into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
7c516b1
Add pages
debuggy May 26, 2020
c6a8ce3
publish plugin
debuggy May 26, 2020
fdd42eb
link
debuggy May 26, 2020
151252f
Update plugin
debuggy Jun 3, 2020
eb3dc45
update plugin
debuggy Jul 8, 2020
f3d28a2
Merge branch 'master' into gh-pages
debuggy Jul 10, 2020
79b5458
Update plugin
debuggy Jul 10, 2020
b7fb2b2
Merge branch 'master' into gh-pages
debuggy Jul 10, 2020
6ab5c06
Update plugin
debuggy Jul 10, 2020
bd266fb
Merge branch 'master' into gh-pages
debuggy Jul 13, 2020
7e41276
Update plugin
debuggy Jul 13, 2020
b7ab571
Merge branch 'master' into gh-pages
debuggy Jul 14, 2020
9c5dce7
Update plugin
debuggy Jul 14, 2020
43f7f86
Update summary
debuggy Jul 14, 2020
9147c64
Update plugin
debuggy Jul 14, 2020
918048e
Merge branch 'master' into gh-pages
debuggy Jul 15, 2020
182c4d7
Update plugin
debuggy Jul 16, 2020
69b56a6
Test submit job v2 plugin
debuggy Jul 16, 2020
0d427f8
update link
debuggy Jul 16, 2020
4128e3a
Fix url link
debuggy Jul 16, 2020
9f55f64
Update plugin.js (#32)
yiyione Jul 17, 2020
f56db1e
Add chunk.js (#33)
yiyione Jul 17, 2020
390f3d4
Merge branch 'master' into gh-pages
debuggy Jul 31, 2020
f7826fd
Update plugin
debuggy Jul 31, 2020
70b04fd
Update new deployment (#43)
debuggy Aug 6, 2020
ee1c8c5
354
debuggy Aug 21, 2020
67a5b52
Merge remote-tracking branch 'origin/gh-pages' into protocol
debuggy Aug 21, 2020
b33405b
Protocol (#45)
debuggy Aug 21, 2020
cb00fdc
Rename couplet_dataset copy.yaml to couplet_dataset.yaml
debuggy Aug 21, 2020
db7f9a1
426
debuggy Aug 21, 2020
b4a847c
New yaml file
debuggy Aug 21, 2020
06858c6
532
debuggy Aug 23, 2020
a37575c
Merge remote-tracking branch 'origin/gh-pages' into protocol
debuggy Aug 23, 2020
84f7dae
Update Protocol (#46)
debuggy Aug 23, 2020
d08768d
845
debuggy Aug 23, 2020
3226936
Merge remote-tracking branch 'origin/gh-pages' into protocol
debuggy Aug 23, 2020
779e7e5
Update protocol examples (#47)
debuggy Aug 23, 2020
91d9128
fix protocol
debuggy Aug 23, 2020
77defc6
Merge remote-tracking branch 'origin/gh-pages' into protocol
debuggy Aug 23, 2020
6197ea1
fix lint
debuggy Aug 23, 2020
b61fd91
fix const variables bug
debuggy Aug 24, 2020
ee88329
Add code wrapper style
debuggy Aug 24, 2020
1f4cfae
delete bk file
debuggy Aug 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions examples/item_protocols/couplet_dataset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
protocolVersion: 2
name: couplet_dataset
type: job
contributor: OpenPAI
description: |
# Couplet Dataset

This is the dataset of couplet.

## Data content

This dataset contains processed data based on [Microsoft AI EDU project](https://github.com/microsoft/ai-edu/blob/master/B-%E5%AE%9E%E8%B7%B5%E6%A1%88%E4%BE%8B/B13-AI%E5%AF%B9%E8%81%94%E7%94%9F%E6%88%90%E6%A1%88%E4%BE%8B/docs/fairseq.md).

The original dataset was downloaded from [Public couplet dataset](https://github.com/wb14123/couplet-dataset) and was splited into ```test, train and valid``` with 98:1:1 proportion. The ```.up``` and ```.down``` files contains upper part and down part of a certain couplet seperately.

## The file stucture

```
.
|-- test.down // down part of couplet
|-- test.up // up part of couplet
|-- train.down
|-- train.up
|-- valid.down
|-- valid.up
```

## How to use it

The data will be mounted at ```DATA_DIR``` environment variable. You could use ```$DATA_DIR``` in your command when submit jobs in pai.

prerequisites:
- name: default_image
type: dockerimage
uri: 'openpai/standard:python_3.6-pytorch_1.2.0-gpu'
- name: couplet_data
type: data
uri :
- /mnt/confignfs/couplet_data

taskRoles:
taskrole:
instances: 1
dockerImage: default_image
data: couplet_data
resourcePerInstance:
cpu: 4
memoryMB: 8192
gpu: 1
commands:
- >-
# The data stored in environment variable DATA_DIR, you could use it in
commands by $DATA_DIR
- export DATA_DIR=<% $data.uri[0] %>

extras:
storages:
- name: confignfs
mountPath: /mnt/confignfs
62 changes: 62 additions & 0 deletions examples/item_protocols/couplet_inference.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
protocolVersion: 2
name: couplet_inference
type: job
contributor: OpenPAI
description: |
# Couplet Training Job Template
This is a model inference process. The input data is the trainning models trained by ```couplet training job```, and the this job will produce a url for user to ask for down part for a upper part of couplet.
## How to use
When use this module, you should set three environment variables:
- ```DATA_DIR```: the training model path in container, by default it uses the output of couplet training job. If you want to use your own models. First make sure mount your models into container, and then change the ```$DATA_DIR``` with the path.
- ```CODE_DIR```: the service code, it will start a server at the given port.
- ```FLASK_RUN_PORT```: the service port container will output.
## How to check the result
After job finished successfully, you could check the job detail to get the container ip and ```flask_port``` number, then go to http://<ip>:<flask_port>/upper=<input> to test the result.
prerequisites:
- name: default_image
type: dockerimage
uri: "openpai/standard:python_3.6-pytorch_1.2.0-gpu"
- name: couplet_data
type: data
uri:
- /mnt/confignfs/couplet/checkpoints
- name: code
type: script
uri: /mnt/confignfs/couplet

taskRoles:
taskrole:
instances: 1
dockerImage: default_image
data: couplet_data
script: code
resourcePerInstance:
cpu: 4
memoryMB: 8192
gpu: 1
ports:
FLASK_PORT: 1
commands:
- export DATA_DIR=<% $data.uri[0] %>
- export CODE_DIR=<% $script.uri %>
- export FLASK_PORT=$PAI_PORT_LIST_taskrole_0_FLASK_PORT
- pip install fairseq
- pip install flask
- pip install gunicorn
- 'cd ${CODE_DIR}'
- 'gunicorn --bind=0.0.0.0:${FLASK_PORT} app:app'

extras:
storages:
- name: confignfs
mountPath: /mnt/confignfs
76 changes: 76 additions & 0 deletions examples/item_protocols/couplet_training.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
protocolVersion: 2
name: couplet_training
type: job
contributor: OpenPAI
description: |
# Couplet Training Job Template
This is a model training process. After training, this model will give a down part with an upper part of couplet. Please refer to Microsoft AI Edu Project for more details.
## Training Data
You could use Couplet Dataset data component as training data, or any dataset follows fairseq model requirements.
## How to use
When use this module, you should set three environment variables:
- ```DATA_DIR```: the training data path in container, by default it uses Couplet Dataset data component. If you want to use your own datasets. First make sure mount your data into container, and then change the ```$DATA_DIR``` with the path.
- PREPROCESSED_DATA_DIR: the path to store intermediate result, by default it is ./processed_data.
- ```OUTPUT_DIR```: the path to store output result, i.e. the training model files. By default it will mount a nfs storage, and you could change it with other mounted storage.
## How to check the result
After job finished successfully, you could check the output model files in the output storage. The storage server url is in details page.
prerequisites:
- name: default_image
type: dockerimage
uri: "openpai/standard:python_3.6-pytorch_1.2.0-gpu"
- name: couplet_data
type: data
uri:
- /mnt/confignfs/couplet_data
- name: output
type: output
uri: /mnt/confignfs/output

taskRoles:
taskrole:
instances: 1
dockerImage: default_image
data: couplet_data
output: output
resourcePerInstance:
cpu: 4
memoryMB: 8192
gpu: 1
commands:
- export DATA_DIR=<% $data.uri[0] %>
- export OUTPUT_DIR=<% $output.uri %>
- export PREPROCESSED_DATA_DIR=./preprocessed_data
- pip install fairseq
- fairseq-preprocess \
- '--source-lang up \'
- '--target-lang down \'
- '--trainpref ${DATA_DIR}/train \'
- '--validpref ${DATA_DIR}/valid \'
- '--testpref ${DATA_DIR}/test \'
- "--destdir ${PREPROCESSED_DATA_DIR}"
- 'fairseq-train ${PREPROCESSED_DATA_DIR} \'
- '--log-interval 100 \'
- '--lr 0.25 \'
- '--clip-norm 0.1 \'
- '--dropout 0.2 \'
- '--criterion label_smoothed_cross_entropy \'
- '--save-dir ${OUTPUT_DIR} \'
- '-a lstm \'
- '--max-tokens 4000 \'
- "--max-epoch 100"

extras:
storages:
- name: confignfs
mountPath: /mnt/confignfs
57 changes: 57 additions & 0 deletions examples/yaml_templates/couplet_dataset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
protocolVersion: 2
name: Couplet Dataset
type: job
contributor: OpenPAI
description: |
# Couplet Dataset
This is the dataset of couplet.
## Data content
This dataset contains processed data based on [Microsoft AI EDU project](https://github.com/microsoft/ai-edu/blob/master/B-%E5%AE%9E%E8%B7%B5%E6%A1%88%E4%BE%8B/B13-AI%E5%AF%B9%E8%81%94%E7%94%9F%E6%88%90%E6%A1%88%E4%BE%8B/docs/fairseq.md).
The original dataset was downloaded from [Public couplet dataset](https://github.com/wb14123/couplet-dataset) and was splited into ```test, train and valid``` with 98:1:1 proportion. The ```.up``` and ```.down``` files contains upper part and down part of a certain couplet seperately.
## The file stucture
```
.
|-- test.down // down part of couplet
|-- test.up // up part of couplet
|-- train.down
|-- train.up
|-- valid.down
|-- valid.up
```
## How to use it
The data will be mounted at ```DATA_DIR``` environment variable. You could use ```$DATA_DIR``` in your command when submit jobs in pai.
prerequisites:
- name: default_image
type: dockerimage
uri: 'openpai/standard:python_3.6-pytorch_1.2.0-gpu'
- name: couplet_data
type: data
uri : /mnt/confignfs/couplet_data

taskRoles:
taskrole:
instances: 1
dockerImage: default_image
resourcePerInstance:
cpu: 4
memoryMB: 8192
gpu: 1
commands:
- >-
# The data stored in environment variable DATA_DIR, you could use it in
commands by $DATA_DIR
- export DATA_DIR= <% $data.uri[0] %>

extras:
storages:
- name: confignfs
mountPath: /mnt/confignfs
10 changes: 10 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<p>Webcome to openpaimarketplace github page! You could use build plugin file as
<a href="https://microsoft.github.io/openpaimarketplace/publish/marketplace/plugin.js">
https://microsoft.github.io/openpaimarketplace/publish/marketplace/plugin.js
</a>
</p>
<p> The submit job v2 plugin file:
<a href="https://microsoft.github.io/openpaimarketplace/publish/submit-job-v2/plugin.js">
https://microsoft.github.io/openpaimarketplace/publish/submit-job-v2/plugin.js
</a>
</p>
79 changes: 79 additions & 0 deletions publish/marketplace/plugin.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions publish/submit-job-v2/1.chunk.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions publish/submit-job-v2/2.chunk.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions publish/submit-job-v2/editor.worker.js

Large diffs are not rendered by default.

835 changes: 835 additions & 0 deletions publish/submit-job-v2/plugin.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions webportal/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"compilerOptions": {
"target": "es2017",
"allowSyntheticDefaultImports": false,
"baseUrl": "./",
"baseUrl": ".",
"paths": {
"App/*": ["src/app/*"]
}
Expand Down
2 changes: 1 addition & 1 deletion webportal/src/app/assets/data.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions webportal/src/app/assets/template.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions webportal/src/app/components/code_wrapper.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import styled from 'styled-components';

const CodeWrapper = styled.pre`
background: #f4f4f4;
border: 1px solid #ddd;
border-left: 3px solid #f36d33;
color: #666;
page-break-inside: avoid;
font-family: monospace;
font-size: 15px;
line-height: 1.6;
margin-bottom: 1.6em;
max-width: 100%;
overflow: auto;
padding: 1em 1.5em;
display: block;
word-wrap: break-word;
`;

export default CodeWrapper;
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ import StorageCard from './storage_card';

const DataDetail = props => {
const { marketItem } = props;
const dataStorages = marketItem.protocol.prerequisites.filter(
item => item.type === 'data',
);

return (
<Stack gap='m'>
<Text variant='large'>Data Storage</Text>
<StorageCard storage={marketItem.content.dataStorage} />
<StorageCard storages={dataStorages} />
</Stack>
);
};
Expand Down
29 changes: 5 additions & 24 deletions webportal/src/app/market_detail/components/old_detail.jsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,19 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { getTheme, Stack, Text } from 'office-ui-fabric-react';
import React, { useEffect, useState } from 'react';
import { Stack, Text } from 'office-ui-fabric-react';
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';

const { palette, spacing } = getTheme();

const Wrapper = styled.div`
background-color: ${palette.neutralLighterAlt};
padding: ${spacing.m};
white-space: pre-wrap;
`;
import yaml from 'js-yaml';
import CodeWrapper from 'App/components/code_wrapper';

const OldDetail = props => {
const { marketItem } = props;
const [protocolText, setProtocolText] = useState('');

useEffect(() => {
async function fetchProtocol() {
const res = await fetch(
`https://microsoft.github.io/openpaimarketplace/examples/yaml_templates/${marketItem.content.config}`,
);
const text = await res.text();
setProtocolText(text);
}
fetchProtocol();
}, []);

return (
<Stack gap='m'>
<Text variant='large'>Protocol</Text>
<Wrapper>{protocolText}</Wrapper>
<CodeWrapper>{yaml.safeDump(marketItem.protocol)}</CodeWrapper>
</Stack>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const PivotCard = props => {
<PivotItemWrapper>
<ReactMarkdown
className='markdown-body'
source={marketItem.description}
source={marketItem.protocol.description}
/>
</PivotItemWrapper>
</PivotItem>
Expand Down
Loading