Skip to content

Commit

Permalink
Merge branch 'devel' into improve-gitlab-api-finder
Browse files Browse the repository at this point in the history
  • Loading branch information
0x2b3bfa0 authored May 27, 2021
2 parents 29b81e9 + 685decb commit bafe6c7
Show file tree
Hide file tree
Showing 40 changed files with 673 additions and 666 deletions.
40 changes: 37 additions & 3 deletions .github/workflows/checkbot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,26 @@ on:
jobs:
# check that CML container builds properly
build-container:
if: contains(github.event.comment.body, '/tests')
if: startsWith(github.event.comment.body, '/tests')
runs-on: [ubuntu-18.04]
steps:
- name: React Seen
uses: actions/github-script@v2
with:
script: |
const perm = await github.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner, repo: context.repo.repo,
username: context.payload.comment.user.login})
if (!["admin", "write"].includes(perm.data.permission)){
github.reactions.createForIssueComment({
owner: context.repo.owner, repo: context.repo.repo,
comment_id: context.payload.comment.id, content: "laugh"})
throw "Permission denied for user " + context.payload.comment.user.login
}
github.reactions.createForIssueComment({
owner: context.repo.owner, repo: context.repo.repo,
comment_id: context.payload.comment.id, content: "eyes"})
github-token: ${{ secrets.TEST_GITHUB_TOKEN }}
- uses: actions/checkout@v2
- name: Build & Publish test image
run: |
Expand Down Expand Up @@ -110,9 +127,26 @@ jobs:
run: |
nvidia-smi
chatbot:
if: contains(github.event.comment.body, '/cml-')
if: startsWith(github.event.comment.body, '/cml-')
runs-on: [ubuntu-latest]
steps:
- name: React Seen
uses: actions/github-script@v2
with:
script: |
const perm = await github.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner, repo: context.repo.repo,
username: context.payload.comment.user.login})
if (!["admin", "write"].includes(perm.data.permission)){
github.reactions.createForIssueComment({
owner: context.repo.owner, repo: context.repo.repo,
comment_id: context.payload.comment.id, content: "laugh"})
throw "Permission denied for user " + context.payload.comment.user.login
}
github.reactions.createForIssueComment({
owner: context.repo.owner, repo: context.repo.repo,
comment_id: context.payload.comment.id, content: "eyes"})
github-token: ${{ secrets.TEST_GITHUB_TOKEN }}
- uses: actions/checkout@v2
- name: chatops
id: chatops
Expand All @@ -133,4 +167,4 @@ jobs:
run: |
npm ci
sudo npm link
${{steps.chatops.outputs.COMMAND}}
# ${{steps.chatops.outputs.COMMAND}}
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img src="imgs/title_strip_trim.png" width=400>
<img src="https://static.iterative.ai/img/cml/title_strip_trim.png" width=400>
</p>

[![GHA](https://img.shields.io/github/v/tag/iterative/setup-cml?label=GitHub%20Actions&logo=GitHub)](https://github.com/iterative/setup-cml)
Expand All @@ -11,10 +11,10 @@ projects. Use it to automate parts of your development workflow, including model
training and evaluation, comparing ML experiments across your project history,
and monitoring changing datasets.

![](imgs/github_cloud_case_lessshadow.png) _On every pull request, CML helps you
automatically train and evaluate models, then generates a visual report with
results and metrics. Above, an example report for a
[neural style transfer model](https://github.com/iterative/cml_cloud_case)._
![](https://static.iterative.ai/img/cml/github_cloud_case_lessshadow.png) _On
every pull request, CML helps you automatically train and evaluate models, then
generates a visual report with results and metrics. Above, an example report for
a [neural style transfer model](https://github.com/iterative/cml_cloud_case)._

We built CML with these principles in mind:

Expand Down Expand Up @@ -149,7 +149,7 @@ cml-publish graph.png --md >> report.md
> [you will need to create a Personal Access Token](https://github.com/iterative/cml/wiki/CML-with-GitLab#variables)
> for this example to work.

![](imgs/fork_project.png)
![](https://static.iterative.ai/img/cml/fork_project.png)

> :warning: The following steps can all be done in the GitHub browser interface.
> However, to follow along with the commands, we recommend cloning your fork to
Expand Down Expand Up @@ -197,13 +197,13 @@ git push origin experiment
5. In GitHub, open up a Pull Request to compare the `experiment` branch to
`master`.

![](imgs/make_pr.png)
![](https://static.iterative.ai/img/cml/make_pr.png)

Shortly, you should see a comment from `github-actions` appear in the Pull
Request with your CML report. This is a result of the `cml-send-comment`
function in your workflow.

![](imgs/cml_first_report.png)
![](https://static.iterative.ai/img/cml/first_report.png)

This is the outline of the CML workflow:

Expand All @@ -223,7 +223,7 @@ downloaded from external sources. [DVC](https://dvc.org) is a common way to
bring data to your CML runner. DVC also lets you visualize how metrics differ
between commits to make reports like this:

![](imgs/dvc_cml_long_report.png)
![](https://static.iterative.ai/img/cml/dvc_long_report.png)

The `.github/workflows/cml.yaml` file used to create this report is:

Expand Down
56 changes: 26 additions & 30 deletions bin/cml-pr.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,41 @@ const print = console.log;
console.log = console.error;

const yargs = require('yargs');
const decamelize = require('decamelize-keys');

const CML = require('../src/cml').default;
const { GIT_REMOTE, GIT_USER_NAME, GIT_USER_EMAIL } = require('../src/cml');

const run = async (opts) => {
const globs = opts._.length ? opts._ : undefined;
const cml = new CML(opts);
print((await cml.pr_create({ ...opts, globs })) || '');
print((await cml.prCreate({ ...opts, globs })) || '');
};

const opts = decamelize(
yargs
.strict()
.usage('Usage: $0 <glob path> ... <glob path>')
.describe('md', 'Output in markdown format [](url).')
.boolean('md')
.default('remote', GIT_REMOTE)
.describe('remote', 'Sets git remote.')
.default('user-email', GIT_USER_EMAIL)
.describe('user-email', 'Sets git user email.')
.default('user-name', GIT_USER_NAME)
.describe('user-name', 'Sets git user name.')
.default('repo')
.describe(
'repo',
'Specifies the repo to be used. If not specified is extracted from the CI ENV.'
)
.default('token')
.describe(
'token',
'Personal access token to be used. If not specified in extracted from ENV REPO_TOKEN.'
)
.default('driver')
.choices('driver', ['github', 'gitlab'])
.describe('driver', 'If not specify it infers it from the ENV.')
.help('h').argv
);

const opts = yargs
.strict()
.usage('Usage: $0 <glob path> ... <glob path>')
.describe('md', 'Output in markdown format [](url).')
.boolean('md')
.default('remote', GIT_REMOTE)
.describe('remote', 'Sets git remote.')
.default('user-email', GIT_USER_EMAIL)
.describe('user-email', 'Sets git user email.')
.default('user-name', GIT_USER_NAME)
.describe('user-name', 'Sets git user name.')
.default('repo')
.describe(
'repo',
'Specifies the repo to be used. If not specified is extracted from the CI ENV.'
)
.default('token')
.describe(
'token',
'Personal access token to be used. If not specified in extracted from ENV REPO_TOKEN.'
)
.default('driver')
.choices('driver', ['github', 'gitlab'])
.describe('driver', 'If not specify it infers it from the ENV.')
.help('h').argv;
run(opts).catch((e) => {
console.error(e);
process.exit(1);
Expand Down
95 changes: 46 additions & 49 deletions bin/cml-publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ const print = console.log;
console.log = console.error;

const fs = require('fs').promises;
const pipe_args = require('../src/pipe-args');
const pipeArgs = require('../src/pipe-args');
const yargs = require('yargs');
const decamelize = require('decamelize-keys');

const CML = require('../src/cml').default;

Expand All @@ -28,53 +27,51 @@ const run = async (opts) => {
else await fs.writeFile(file, output);
};

pipe_args.load('binary');
const data = pipe_args.piped_arg();
const opts = decamelize(
yargs
.strict()
.usage(`Usage: $0 <path to file>`)
.describe('md', 'Output in markdown format [title || name](url).')
.boolean('md')
.describe('md', 'Output in markdown format [title || name](url).')
.default('title')
.describe('title', 'Markdown title [title](url) or ![](url title).')
.alias('title', 't')
.boolean('native')
.describe(
'native',
"Uses driver's native capabilities to upload assets instead of CML's storage. Currently only available for GitLab CI."
)
.alias('native', 'gitlab-uploads')
.boolean('rm-watermark')
.describe('rm-watermark', 'Avoid CML watermark.')
.default('mime-type')
.describe(
'mime-type',
'Specifies the mime-type. If not set guess it from the content.'
)
.default('file')
.describe(
'file',
'Append the output to the given file. Create it if does not exist.'
)
.alias('file', 'f')
.default('repo')
.describe(
'repo',
'Specifies the repo to be used. If not specified is extracted from the CI ENV.'
)
.default('token')
.describe(
'token',
'Personal access token to be used. If not specified, extracted from ENV REPO_TOKEN, GITLAB_TOKEN, GITHUB_TOKEN, or BITBUCKET_TOKEN.'
)
.default('driver')
.choices('driver', ['github', 'gitlab'])
.describe('driver', 'If not specify it infers it from the ENV.')
.help('h')
.demand(data ? 0 : 1).argv
);
pipeArgs.load('binary');
const data = pipeArgs.pipedArg();
const opts = yargs
.strict()
.usage(`Usage: $0 <path to file>`)
.describe('md', 'Output in markdown format [title || name](url).')
.boolean('md')
.describe('md', 'Output in markdown format [title || name](url).')
.default('title')
.describe('title', 'Markdown title [title](url) or ![](url title).')
.alias('title', 't')
.boolean('native')
.describe(
'native',
"Uses driver's native capabilities to upload assets instead of CML's storage. Currently only available for GitLab CI."
)
.alias('native', 'gitlab-uploads')
.boolean('rm-watermark')
.describe('rm-watermark', 'Avoid CML watermark.')
.default('mime-type')
.describe(
'mime-type',
'Specifies the mime-type. If not set guess it from the content.'
)
.default('file')
.describe(
'file',
'Append the output to the given file. Create it if does not exist.'
)
.alias('file', 'f')
.default('repo')
.describe(
'repo',
'Specifies the repo to be used. If not specified is extracted from the CI ENV.'
)
.default('token')
.describe(
'token',
'Personal access token to be used. If not specified, extracted from ENV REPO_TOKEN, GITLAB_TOKEN, GITHUB_TOKEN, or BITBUCKET_TOKEN.'
)
.default('driver')
.choices('driver', ['github', 'gitlab'])
.describe('driver', 'If not specify it infers it from the ENV.')
.help('h')
.demand(data ? 0 : 1).argv;

run({ ...opts, data }).catch((e) => {
console.error(e);
Expand Down
Loading

1 comment on commit bafe6c7

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

Please sign in to comment.