-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from valohai/open-proj
Project and execution opening commands
- Loading branch information
Showing
9 changed files
with
96 additions
and
4 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import webbrowser | ||
|
||
from tests.commands.execution.utils import get_execution_data_mock | ||
from tests.utils import make_call_stub | ||
from valohai_cli.commands.execution.open import open | ||
|
||
|
||
def test_open(monkeypatch, runner, logged_in_and_linked): | ||
call_stub = make_call_stub() | ||
monkeypatch.setattr(webbrowser, 'open', call_stub) | ||
with get_execution_data_mock(): | ||
runner.invoke(open, ['7'], catch_exceptions=False) | ||
assert call_stub.calls |
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,17 @@ | ||
import webbrowser | ||
|
||
import requests_mock | ||
|
||
from tests.fixture_data import PROJECT_DATA | ||
from tests.utils import make_call_stub | ||
from valohai_cli.commands.project.open import open | ||
|
||
|
||
def test_open(monkeypatch, runner, logged_in_and_linked): | ||
call_stub = make_call_stub() | ||
monkeypatch.setattr(webbrowser, 'open', call_stub) | ||
with requests_mock.mock() as m: | ||
project_data = dict(PROJECT_DATA) | ||
m.get('https://app.valohai.com/api/v0/projects/{id}/'.format(id=project_data['id']), json=project_data) | ||
runner.invoke(open, catch_exceptions=False) | ||
assert call_stub.calls |
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
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,14 @@ | ||
import click | ||
|
||
from valohai_cli.ctx import get_project | ||
from valohai_cli.utils import open_browser | ||
|
||
|
||
@click.command() | ||
@click.argument('counter') | ||
def open(counter): | ||
""" | ||
Open an execution in a web browser. | ||
""" | ||
execution = get_project(require=True).get_execution_from_counter(counter=counter, detail=True) | ||
open_browser(execution) |
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,15 @@ | ||
import click | ||
|
||
from valohai_cli.api import request | ||
from valohai_cli.ctx import get_project | ||
from valohai_cli.utils import open_browser | ||
|
||
|
||
@click.command() | ||
def open(): | ||
""" | ||
Open the project's view in a web browser. | ||
""" | ||
project = get_project(require=True) | ||
project_data = request('get', '/api/v0/projects/{id}/'.format(id=project.id)).json() | ||
open_browser(project_data) |
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