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

enhance(runtime): runtime quickstart will create workdir automatically #1254

Merged
merged 1 commit into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions client/starwhale/core/runtime/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def quickstart() -> None:

@quickstart.command("uri")
@click.argument("uri", required=True)
@click.argument("workdir", required=True, type=click.Path(exists=True, file_okay=False))
@click.argument("workdir", required=True)
@click.option("-f", "--force", is_flag=True, help="Force to quickstart")
@click.option("-n", "--name", default="", help="Runtime name")
@click.option(
Expand Down Expand Up @@ -63,7 +63,7 @@ def _quickstart_from_uri(


@quickstart.command("shell", help="Quickstart from interactive shell")
@click.argument("workdir", type=click.Path(exists=True, file_okay=False))
@click.argument("workdir", required=True)
@click.option("-f", "--force", is_flag=True, help="Force to quickstart")
@click.option(
"-p",
Expand Down
7 changes: 5 additions & 2 deletions client/starwhale/core/runtime/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,12 +752,15 @@ def list(
@classmethod
def quickstart_from_uri(
cls,
workdir: Path,
workdir: t.Union[Path, str],
goldenxinxing marked this conversation as resolved.
Show resolved Hide resolved
name: str,
uri: URI,
force: bool = False,
restore: bool = False,
) -> None:
workdir = Path(workdir).absolute()
ensure_dir(workdir)

if uri.instance_type == InstanceType.CLOUD:
console.print(f":cloud: copy runtime from {uri} to local")
_dest_project_uri = f"{STANDALONE_INSTANCE}/project/{DEFAULT_PROJECT}"
Expand Down Expand Up @@ -835,6 +838,7 @@ def quickstart_from_ishell(
interactive: bool = False,
) -> None:
workdir = Path(workdir).absolute()
ensure_dir(workdir)
console.print(f":printer: render runtime.yaml @ {workdir}")
python_version = get_python_version()

Expand All @@ -849,7 +853,6 @@ def quickstart_from_ishell(
console.print(
f":construction_worker: create {mode} isolated python environment..."
)
ensure_dir(workdir)
_id = create_python_env(
mode=mode,
name=name,
Expand Down
2 changes: 1 addition & 1 deletion client/starwhale/core/runtime/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def list(
@classmethod
def quickstart_from_uri(
cls,
workdir: Path,
workdir: t.Union[Path, str],
name: str,
uri: URI,
force: bool = False,
Expand Down
4 changes: 2 additions & 2 deletions client/tests/core/test_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ def test_quickstart_from_uri(
name = "rttest"
version = "112233"
cloud_uri = URI(f"http://0.0.0.0:80/project/1/runtime/{name}/version/{version}")
ensure_dir(workdir / ".extract")
extract_dir = workdir / ".extract"
ensure_dir(extract_dir)

runtime_config = self.get_runtime_config()
runtime_config["name"] = name
extract_dir = workdir / ".extract"
ensure_file(
extract_dir / DefaultYAMLName.RUNTIME,
content=yaml.safe_dump(runtime_config),
Expand Down