Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cml runner --cloud-gpu to accept nogpu #747

Merged
merged 4 commits into from
Sep 24, 2021

Conversation

dacbd
Copy link
Contributor

@dacbd dacbd commented Sep 24, 2021

@dacbd dacbd marked this pull request as ready for review September 24, 2021 16:11
@dacbd
Copy link
Contributor Author

dacbd commented Sep 24, 2021

Functional test:

dabarnes@ubuntu:~/projects/cml$ ./bin/cml.js runner \
>     --single \
>     --log=debug \
>     --idle-timeout=1800 \
>     --token=xxx \
>     --cloud=gcp \
>     --cloud-region=us-west \
>     --cloud-type=m \
>     --cloud-gpu=nogpu \
>     --repo=xxx \
>     --driver=github \
>     --cloud-hdd-size=10
info: Preparing workdir /home/dabarnes/.cml/cml-2g7sdfdtiy...
info: Deploying cloud runner plan...
info: Terraform apply...
info: {"awsSecurityGroup":null,"cloud":"gcp","driver":"github","id":"iterative-34qzkcov8n4ws","idleTimeout":1800,"image":null,"instanceGpu":null,"instanceHddSize":10,"instanceIp":"xxx","instanceLaunchTime":"2021-09-24 09:05:45.397746969 -0700 PDT m=+28.798050565","instanceType":"m","labels":"cml","name":"cml-2g7sdfdtiy","region":"us-west","repo":"xxx","single":true,"spot":false,"spotPrice":-1,"timeouts":null}

@@ -469,7 +469,7 @@ exports.builder = (yargs) =>
},
cloudGpu: {
type: 'string',
choices: ['nogpu', 'k80', 'v100', 'tesla'],
choices: ['nogpu', 'k80', 'v100', 'tesla', null],
Copy link
Contributor

@DavidGOrtega DavidGOrtega Sep 24, 2021

Choose a reason for hiding this comment

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

Interesting that this is not working. It was as far as I remember. Maybe using undefined in the coerce function do the trick? If thats the case maybe is better than null explicitly which is going to be a difficult type to setup

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried changing the value and it seemed that if the result of the coerce function isn't in the choices array then it fails.
My very first patch was to set it to 'nogpu' instead of null which worked fine.
I opted to add null as an option instead to preserve the truthy/falsy behavior in ternary statements.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try this and we can see.

        choices: ['nogpu', 'k80', 'v100', 'tesla'],
        coerce: (val) => (val === 'nogpu' ? undefined : val),

Copy link
Contributor

Choose a reason for hiding this comment

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

Thats what I suggested

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DavidGOrtega It looks like undefined behaves as expected, Im going to do a full test in our gcp env and if it works as expected I'll update the PR.

Copy link
Member

Choose a reason for hiding this comment

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

See also yargs/yargs#756

Copy link
Contributor

Choose a reason for hiding this comment

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

@DavidGOrtega It looks like undefined behaves as expected, Im going to do a full test in our gcp env and if it works as expected I'll update the PR.

@danielbarnes that was my intuition, since its allowing you to not set it, I would say that this worked also with null previously, but not sure... JS and its non "Good parts" 🙏

Copy link
Contributor Author

@dacbd dacbd Sep 24, 2021

Choose a reason for hiding this comment

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

JS and its non "Good parts" 🙏

🤣

@dacbd dacbd mentioned this pull request Sep 24, 2021
@dacbd dacbd marked this pull request as draft September 24, 2021 18:40
@dacbd dacbd temporarily deployed to external September 24, 2021 18:46 Inactive
@dacbd
Copy link
Contributor Author

dacbd commented Sep 24, 2021

Updated to use undefined vs null works as expected from my test:

dabarnes@ubuntu:~/projects/cml$ ./bin/cml.js runner \
>     --single \
>     --log=debug \
>     --idle-timeout=1800 \
>     --token=xxx\
>     --cloud=gcp \
>     --cloud-region=us-west \
>     --cloud-type=m \
>     --cloud-gpu=nogpu \
>     --repo=xxx \
>     --driver=github \
>     --cloud-hdd-size=10
info: Preparing workdir /home/dabarnes/.cml/cml-jnnd5x6sq0...
info: Deploying cloud runner plan...
info: Terraform apply...
info: {"awsSecurityGroup":null,"cloud":"gcp","driver":"github","id":"iterative-2v4cyhm47w2q7","idleTimeout":1800,"image":null,"instanceGpu":null,"instanceHddSize":10,"instanceIp":"xxx","instanceLaunchTime":"2021-09-24 11:41:41.997215239 -0700 PDT m=+24.104635525","instanceType":"m","labels":"cml","name":"cml-jnnd5x6sq0","region":"us-west","repo":"xxx","single":true,"spot":false,"spotPrice":-1,"timeouts":null}

@dacbd dacbd marked this pull request as ready for review September 24, 2021 18:49
@0x2b3bfa0 0x2b3bfa0 changed the title --cloud-gpu patch Fix cml runner --cloud-gpu to accept nogpu Sep 24, 2021
@0x2b3bfa0 0x2b3bfa0 merged commit fdd0acd into iterative:master Sep 24, 2021
@0x2b3bfa0
Copy link
Member

Thank you very much, @danielbarnes!

@DavidGOrtega
Copy link
Contributor

Thank you very much, @danielbarnes!

I subscribe!!! Thanks @danielbarnes

@casperdcl casperdcl added bug Something isn't working cml-runner Subcommand labels Sep 27, 2021
@DavidGOrtega DavidGOrtega mentioned this pull request Oct 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cml-runner Subcommand
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CML runner error parsing cloud-gpu
5 participants