From c4cd1dce277c33936f141ea475ccdaf753ae882b Mon Sep 17 00:00:00 2001 From: Mohammad Alisafaee Date: Thu, 26 Jan 2023 22:56:10 +0100 Subject: [PATCH] update templates --- renku/ui/cli/init.py | 24 +++++------ renku/version.py | 2 +- tests/cli/test_init.py | 4 +- tests/cli/test_template.py | 43 +++++++++---------- tests/core/commands/test_merge.py | 18 ++++---- tests/fixtures/repository.py | 2 +- tests/fixtures/templates.py | 6 +-- tests/service/fixtures/service_integration.py | 2 +- 8 files changed, 49 insertions(+), 52 deletions(-) diff --git a/renku/ui/cli/init.py b/renku/ui/cli/init.py index 4446aaa7fb..e0791024d3 100644 --- a/renku/ui/cli/init.py +++ b/renku/ui/cli/init.py @@ -69,9 +69,9 @@ ... OK INDEX ID DESCRIPTION PARAMETERS - ----- -------------- -------------------------- ---------------------- - 1 python-minimal Basic Python Project:[...] description: proj[...] - 2 R-minimal Basic R Project: The [...] description: proj[...] + ----- ------ -------------------------- ---------------------- + 1 python Basic Python Project:[...] description: proj[...] + 2 R Basic R Project: The [...] description: proj[...] Please choose a template by typing the index: @@ -86,7 +86,7 @@ .. code-block:: console - $ renku init --template-id python-minimal --parameter \ + $ renku init --template-id python --parameter \ "description"="my new shiny project" Initializing new Renku repository... OK @@ -113,7 +113,7 @@ "@type": "https://schema.org/Organization", \ "https://schema.org/legalName": "ETHZ"}' > metadata.json - $ renku init --template-id python-minimal --parameter \ + $ renku init --template-id python --parameter \ "description"="my new shiny project" --metadata metadata.json Initializing new Renku repository... OK @@ -136,13 +136,13 @@ $ echo "FROM python:3.7-alpine" > Dockerfile $ renku init - INDEX ID PARAMETERS - ------- -------------- ------------ - 1 python-minimal description - 2 R-minimal description - 3 bioc-minimal description - 4 julia-minimal description - 5 minimal + INDEX ID PARAMETERS + ------- --------- ------------ + 1 python description + 2 R description + 3 bioc description + 4 julia description + 5 minimal Please choose a template by typing the index: 1 The template requires a value for "description": Test Project Initializing Git repository... diff --git a/renku/version.py b/renku/version.py index a53942a2ff..303a9ba316 100644 --- a/renku/version.py +++ b/renku/version.py @@ -25,7 +25,7 @@ from importlib_metadata import distribution, version # type: ignore __version__ = version("renku") -__template_version__ = "0.3.5" +__template_version__ = "0.4.1" __minimum_project_version__ = "1.7.0" diff --git a/tests/cli/test_init.py b/tests/cli/test_init.py index f40f1aa10c..cec12f7836 100644 --- a/tests/cli/test_init.py +++ b/tests/cli/test_init.py @@ -67,8 +67,8 @@ def test_template_selection_helpers(isolated_runner): assert "Please choose a template by typing its index:" in stripped_output - assert "1 python-minimal" in stripped_output - assert "2 R-minimal" in stripped_output + assert "1 python" in stripped_output + assert "2 R" in stripped_output def test_init(isolated_runner, project_init): diff --git a/tests/cli/test_template.py b/tests/cli/test_template.py index 2f629ab51a..40f4b3a242 100644 --- a/tests/cli/test_template.py +++ b/tests/cli/test_template.py @@ -46,7 +46,7 @@ def test_template_list(isolated_runner): result = isolated_runner.invoke(cli, command, replace_argv=False) assert 0 == result.exit_code, format_result_exception(result) - assert "python-minimal" in result.output + assert "python" in result.output finally: sys.argv = argv @@ -62,14 +62,14 @@ def test_template_list_from_source(isolated_runner): result = isolated_runner.invoke(cli, command + ["--source", TEMPLATES_URL]) assert 0 == result.exit_code, format_result_exception(result) - assert "python-minimal" in result.output - assert "julia-minimal" in result.output + assert "python" in result.output + assert "julia" in result.output result = isolated_runner.invoke(cli, command + ["-s", TEMPLATES_URL, "--reference", "0.3.2"]) assert 0 == result.exit_code, format_result_exception(result) - assert "python-minimal" in result.output - assert "julia-minimal" in result.output + assert "python" in result.output + assert "julia" in result.output finally: sys.argv = argv @@ -81,7 +81,7 @@ def test_template_show(isolated_runner): sys.argv = command try: - result = isolated_runner.invoke(cli, command + ["R-minimal"]) + result = isolated_runner.invoke(cli, command + ["R"]) assert 0 == result.exit_code, format_result_exception(result) assert re.search("^Name: Basic R (.*) Project$", result.output, re.MULTILINE) is not None @@ -135,18 +135,18 @@ def test_template_set_failure(runner, project, with_injection): assert 1 == result.exit_code, format_result_exception(result) assert "Project already has a template" in result.output with with_injection(): - assert "python-minimal" == project_context.project.template_metadata.template_id + assert "python" == project_context.project.template_metadata.template_id def test_template_set(runner, project, with_injection): """Test setting a new template in a project.""" from renku.version import __template_version__ - result = runner.invoke(cli, ["template", "set", "--force", "R-minimal"]) + result = runner.invoke(cli, ["template", "set", "--force", "R"]) assert 0 == result.exit_code, format_result_exception(result) with with_injection(): - assert "R-minimal" == project_context.project.template_metadata.template_id + assert "R" == project_context.project.template_metadata.template_id assert __template_version__ == project_context.project.template_metadata.template_version assert __template_version__ == project_context.project.template_metadata.template_ref @@ -158,11 +158,11 @@ def test_template_set_overwrites_modified(runner, project, with_injection): """Test setting a new template in a project overwrite modified files.""" write_and_commit_file(project.repository, "Dockerfile", "my-modifications") - result = runner.invoke(cli, ["template", "set", "--force", "R-minimal"]) + result = runner.invoke(cli, ["template", "set", "--force", "R"]) assert 0 == result.exit_code, format_result_exception(result) with with_injection(): - assert "R-minimal" == project_context.project.template_metadata.template_id + assert "R" == project_context.project.template_metadata.template_id assert "my-modifications" not in (project.path / "Dockerfile").read_text() assert not project.repository.is_dirty(untracked_files=True) @@ -172,11 +172,11 @@ def test_template_set_interactive(runner, project, with_injection, overwrite, fo """Test setting a template in interactive mode.""" write_and_commit_file(project.repository, "Dockerfile", "my-modifications") - result = runner.invoke(cli, ["template", "set", "-f", "R-minimal", "-i"], input=f"{overwrite}\n" * 420) + result = runner.invoke(cli, ["template", "set", "-f", "R", "-i"], input=f"{overwrite}\n" * 420) assert 0 == result.exit_code, format_result_exception(result) with with_injection(): - assert "R-minimal" == project_context.project.template_metadata.template_id + assert "R" == project_context.project.template_metadata.template_id assert ("my-modifications" in (project.path / "Dockerfile").read_text()) is found assert not project.repository.is_dirty(untracked_files=True) @@ -187,7 +187,7 @@ def test_template_set_preserve_renku_version(runner, project): new_content = re.sub(r"^\s*ARG RENKU_VERSION=(.+)$", "ARG RENKU_VERSION=0.0.42", content, flags=re.MULTILINE) write_and_commit_file(project.repository, "Dockerfile", new_content) - result = runner.invoke(cli, ["template", "set", "-f", "R-minimal", "--interactive"], input="y\n" * 420) + result = runner.invoke(cli, ["template", "set", "-f", "R", "--interactive"], input="y\n" * 420) assert 0 == result.exit_code, format_result_exception(result) @@ -212,7 +212,7 @@ def test_template_set_uses_renku_version_when_non_existing(tmpdir, runner): assert "RENKU_VERSION" not in project_context.docker_path.read_text() - assert 0 == runner.invoke(cli, ["template", "set", "python-minimal"]).exit_code + assert 0 == runner.invoke(cli, ["template", "set", "python"]).exit_code assert f"RENKU_VERSION={__version__}" in project_context.docker_path.read_text() @@ -221,7 +221,7 @@ def test_template_set_dry_run(runner, project): """Test set dry-run doesn't make any changes.""" commit_sha_before = project.repository.head.commit.hexsha - result = runner.invoke(cli, ["template", "set", "-f", "R-minimal", "--dry-run"]) + result = runner.invoke(cli, ["template", "set", "-f", "R", "--dry-run"]) assert 0 == result.exit_code, format_result_exception(result) assert not project.repository.is_dirty() @@ -232,14 +232,12 @@ def test_template_set_dry_run(runner, project): def test_template_update(runner, project, with_injection): """Test updating a template.""" result = runner.invoke( - cli, - ["template", "set", "-f", "python-minimal", "-s", TEMPLATES_URL, "-r", "0.3.2"] - + ["-p", "description=fixed-version"], + cli, ["template", "set", "-f", "python", "-s", TEMPLATES_URL, "-r", "0.3.2", "-p", "description=fixed-version"] ) assert 0 == result.exit_code, format_result_exception(result) with with_injection(): - assert "python-minimal" == project_context.project.template_metadata.template_id + assert "python" == project_context.project.template_metadata.template_id assert "0.3.2" == project_context.project.template_metadata.template_ref assert "b9ab266fba136bdecfa91dc8d7b6d36b9d427012" == project_context.project.template_metadata.template_version @@ -248,7 +246,7 @@ def test_template_update(runner, project, with_injection): assert 0 == result.exit_code, format_result_exception(result) assert "Template is up-to-date" not in result.output with with_injection(): - assert "python-minimal" == project_context.project.template_metadata.template_id + assert "python" == project_context.project.template_metadata.template_id assert Version(project_context.project.template_metadata.template_ref) > Version("0.3.2") assert "6c59d8863841baeca8f30062fd16c650cf67da3b" != project_context.project.template_metadata.template_version @@ -284,8 +282,7 @@ def test_template_update_dry_run(runner, project): """Test update dry-run doesn't make any changes.""" result = runner.invoke( cli, - ["template", "set", "-f", "python-minimal", "-s", TEMPLATES_URL, "-r", "0.3.2"] - + ["-p", "description=fixed-version"], + ["template", "set", "-f", "python", "-s", TEMPLATES_URL, "-r", "0.3.2", "-p", "description=fixed-version"], ) assert 0 == result.exit_code, format_result_exception(result) diff --git a/tests/core/commands/test_merge.py b/tests/core/commands/test_merge.py index 2ca86bc8d6..83b7774930 100644 --- a/tests/core/commands/test_merge.py +++ b/tests/core/commands/test_merge.py @@ -310,7 +310,7 @@ def test_merge_project_both_template_changed(mocker): creator=Person.from_string("John Doe "), name="my-project", template_metadata=ProjectTemplateMetadata( - template_id="python-minimal", + template_id="python", template_source="renku", template_ref="master", template_version="abcdef", @@ -320,7 +320,7 @@ def test_merge_project_both_template_changed(mocker): creator=Person.from_string("John Doe "), name="my-project", template_metadata=ProjectTemplateMetadata( - template_id="python-minimal1", + template_id="python1", template_source="renku1", template_ref="master1", template_version="12345", @@ -330,7 +330,7 @@ def test_merge_project_both_template_changed(mocker): creator=Person.from_string("John Doe "), name="my-project", template_metadata=ProjectTemplateMetadata( - template_id="python-minimal2", + template_id="python2", template_source="renku2", template_ref="master2", template_version="78910", @@ -356,7 +356,7 @@ def test_merge_project_local_template_changed(): creator=Person.from_string("John Doe "), name="my-project", template_metadata=ProjectTemplateMetadata( - template_id="python-minimal", + template_id="python", template_source="renku", template_ref="master", template_version="abcdef", @@ -366,7 +366,7 @@ def test_merge_project_local_template_changed(): creator=Person.from_string("John Doe "), name="my-project", template_metadata=ProjectTemplateMetadata( - template_id="python-minimal1", + template_id="python1", template_source="renku1", template_ref="master1", template_version="12345", @@ -376,7 +376,7 @@ def test_merge_project_local_template_changed(): creator=Person.from_string("John Doe "), name="my-project", template_metadata=ProjectTemplateMetadata( - template_id="python-minimal", + template_id="python", template_source="renku", template_ref="master", template_version="abcdef", @@ -394,7 +394,7 @@ def test_merge_project_remote_template_changed(): creator=Person.from_string("John Doe "), name="my-project", template_metadata=ProjectTemplateMetadata( - template_id="python-minimal", + template_id="python", template_source="renku", template_ref="master", template_version="abcdef", @@ -404,7 +404,7 @@ def test_merge_project_remote_template_changed(): creator=Person.from_string("John Doe "), name="my-project", template_metadata=ProjectTemplateMetadata( - template_id="python-minimal", + template_id="python", template_source="renku", template_ref="master", template_version="abcdef", @@ -414,7 +414,7 @@ def test_merge_project_remote_template_changed(): creator=Person.from_string("John Doe "), name="my-project", template_metadata=ProjectTemplateMetadata( - template_id="python-minimal1", + template_id="python1", template_source="renku1", template_ref="master1", template_version="12345", diff --git a/tests/fixtures/repository.py b/tests/fixtures/repository.py index 670d67216e..3f132b64ff 100644 --- a/tests/fixtures/repository.py +++ b/tests/fixtures/repository.py @@ -104,7 +104,7 @@ def project(fake_home) -> Generator[RenkuProject, None, None]: with isolated_filesystem(fake_home.parent, delete=True) as project_path: with project_context.with_path(project_path): communication.disable() - result = RenkuRunner().invoke(init, [".", "--template-id", "python-minimal"], "\n", catch_exceptions=False) + result = RenkuRunner().invoke(init, [".", "--template-id", "python"], "\n", catch_exceptions=False) communication.enable() assert 0 == result.exit_code, format_result_exception(result) diff --git a/tests/fixtures/templates.py b/tests/fixtures/templates.py index f8c2d01342..78ba51f66e 100644 --- a/tests/fixtures/templates.py +++ b/tests/fixtures/templates.py @@ -35,7 +35,7 @@ def template_metadata(): yield { "__template_source__": "renku", "__template_ref__": renku_version, - "__template_id__": "python-minimal", + "__template_id__": "python", "__namespace__": "", "__repository__": "", "__project_description__": "no description", @@ -49,7 +49,7 @@ def template(template_metadata): """Yield template data.""" template = { "url": "https://github.com/SwissDataScienceCenter/renku-project-template", - "id": "python-minimal", + "id": "python", "index": 1, "ref": "master", # TODO: Add template parameters here once parameters are added to the template. @@ -78,7 +78,7 @@ def project_init(template): "--template-ref", template["ref"], "--template-id", - "python-minimal", + "python", data["test_project"], ], "init_custom_template": ( diff --git a/tests/service/fixtures/service_integration.py b/tests/service/fixtures/service_integration.py index 6020f37fef..6b45e8ef1c 100644 --- a/tests/service/fixtures/service_integration.py +++ b/tests/service/fixtures/service_integration.py @@ -239,7 +239,7 @@ def _mock_owner(self, data, **kwargs): with chdir(remote_repo_checkout_path): result = runner.invoke( - cli, ["init", ".", "--template-id", "python-minimal", "--force"], "\n", catch_exceptions=False + cli, ["init", ".", "--template-id", "python", "--force"], "\n", catch_exceptions=False ) assert 0 == result.exit_code, format_result_exception(result)