-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
machine: Add a new command dvc machine status
#6649
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e3004fc
machine: Add a new command `dvc machine status`
karajan1001 db743f4
Update dvc/command/machine.py
karajan1001 a4e8d83
Update dvc/command/machine.py
karajan1001 6ee958f
Update machine.py
karajan1001 d65fdab
Remove sensitive fields
karajan1001 74dccc4
Update dvc/machine/__init__.py
karajan1001 df5d636
Update tests/func/machine/__init__.py
karajan1001 0f2f621
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 6569b47
Use white list to limit shown fields
karajan1001 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import textwrap | ||
|
||
CONFIG_TEXT = textwrap.dedent( | ||
"""\ | ||
[feature] | ||
machine = true | ||
['machine \"foo\"'] | ||
karajan1001 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
cloud = aws | ||
""" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import json | ||
|
||
from tpi.terraform import TerraformBackend | ||
|
||
from dvc.command.machine import CmdMachineStatus | ||
from dvc.main import main | ||
|
||
from . import CONFIG_TEXT | ||
|
||
STATUS = """{ | ||
"aws_security_group": null, | ||
"cloud": "aws", | ||
"id": "iterative-2jyhw8j9ieov6", | ||
"image": "ubuntu-bionic-18.04-amd64-server-20210818", | ||
"instance_gpu": null, | ||
"instance_hdd_size": 35, | ||
"instance_ip": "123.123.123.123", | ||
"instance_launch_time": "2021-08-25T07:13:03Z", | ||
"instance_type": "m", | ||
"name": "test-resource", | ||
"region": "us-west", | ||
"spot": false, | ||
"spot_price": -1, | ||
"ssh_name": null, | ||
"ssh_private": "-----BEGIN RSA PRIVATE KEY-----\\n", | ||
"startup_script": "IyEvYmluL2Jhc2g=", | ||
"timeouts": null | ||
}""" | ||
|
||
|
||
def test_status(tmp_dir, scm, dvc, mocker, capsys): | ||
(tmp_dir / ".dvc" / "config").write_text(CONFIG_TEXT) | ||
status = json.loads(STATUS) | ||
|
||
mocker.patch.object( | ||
TerraformBackend, "instances", autospec=True, return_value=[status] | ||
) | ||
|
||
assert main(["machine", "status", "foo"]) == 0 | ||
cap = capsys.readouterr() | ||
assert "instance_num_1:" in cap.out | ||
for key, value in CmdMachineStatus.SENSITIVE_FIELDS: | ||
if key in {"ssh_private", "startup_script"}: | ||
assert f"\t{key:20}: (sensitive value)" in cap.out | ||
else: | ||
assert f"\t{key:20}: {value}" in cap.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be a table, more like dvc stage list, to make it easier to parse? We are trying to have default outputs that are both easy to read and parse if possible.