Skip to content

Commit

Permalink
chore: revert templates id changes
Browse files Browse the repository at this point in the history
This reverts commit d46b054.
  • Loading branch information
m-alisafaee committed Feb 9, 2023
1 parent e5df1fa commit e1960c1
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 63 deletions.
21 changes: 10 additions & 11 deletions .github/workflows/test_deploy.yml
Expand Up @@ -9,7 +9,6 @@ on:
env:
DEPENDENCY_CACHE_PREFIX: "v2"
NETWORK_CACHE_PREFIX: "v1"
TEMPLATES_VERSION: "0.4.1" # To create a new cache key when only templates are updated
jobs:
set-matrix:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -62,7 +61,7 @@ jobs:
path: |
${{ env.pythonLocation }}
renku/templates
key: ${{ env.DEPENDENCY_CACHE_PREFIX }}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}-${{ hashFiles('Makefile') }}-${{ env.TEMPLATES_VERSION }}
key: ${{env.DEPENDENCY_CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
- name: Install dependencies
if: steps.dependency-cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
env:
Expand Down Expand Up @@ -114,7 +113,7 @@ jobs:
path: |
${{ env.pythonLocation }}
renku/templates
key: ${{ env.DEPENDENCY_CACHE_PREFIX }}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}-${{ hashFiles('Makefile') }}-${{ env.TEMPLATES_VERSION }}
key: ${{env.DEPENDENCY_CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
- name: Install dependencies
if: steps.dependency-cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
env:
Expand Down Expand Up @@ -159,7 +158,7 @@ jobs:
path: |
${{ env.pythonLocation }}
renku/templates
key: ${{ env.DEPENDENCY_CACHE_PREFIX }}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}-${{ hashFiles('Makefile') }}-${{ env.TEMPLATES_VERSION }}
key: ${{env.DEPENDENCY_CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
- name: Install dependencies
if: steps.dependency-cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
env:
Expand Down Expand Up @@ -202,7 +201,7 @@ jobs:
path: |
${{ env.pythonLocation }}
renku/templates
key: ${{ env.DEPENDENCY_CACHE_PREFIX }}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}-${{ hashFiles('Makefile') }}-${{ env.TEMPLATES_VERSION }}
key: ${{env.DEPENDENCY_CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
- name: Install dependencies
if: steps.dependency-cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
run: |
Expand Down Expand Up @@ -249,7 +248,7 @@ jobs:
path: |
${{ env.pythonLocation }}
renku/templates
key: ${{ env.DEPENDENCY_CACHE_PREFIX }}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}-${{ hashFiles('Makefile') }}-${{ env.TEMPLATES_VERSION }}
key: ${{env.DEPENDENCY_CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
- name: Install dependencies
if: steps.dependency-cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
env:
Expand Down Expand Up @@ -320,7 +319,7 @@ jobs:
path: |
${{ env.pythonLocation }}
renku/templates
key: ${{ env.DEPENDENCY_CACHE_PREFIX }}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}-${{ hashFiles('Makefile') }}-${{ env.TEMPLATES_VERSION }}
key: ${{env.DEPENDENCY_CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
- name: Install dependencies
if: steps.dependency-cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
env:
Expand Down Expand Up @@ -397,7 +396,7 @@ jobs:
path: |
${{ env.pythonLocation }}
renku/templates
key: ${{ env.DEPENDENCY_CACHE_PREFIX }}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}-${{ hashFiles('Makefile') }}-${{ env.TEMPLATES_VERSION }}
key: ${{env.DEPENDENCY_CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
- name: Install dependencies
if: steps.dependency-cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
env:
Expand Down Expand Up @@ -474,7 +473,7 @@ jobs:
path: |
${{ env.pythonLocation }}
renku/templates
key: ${{ env.DEPENDENCY_CACHE_PREFIX }}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}-${{ hashFiles('Makefile') }}-${{ env.TEMPLATES_VERSION }}
key: ${{env.DEPENDENCY_CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
- name: Install dependencies
if: steps.dependency-cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
env:
Expand Down Expand Up @@ -710,7 +709,7 @@ jobs:
path: |
${{ env.pythonLocation }}
renku/templates
key: ${{ env.DEPENDENCY_CACHE_PREFIX }}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}-${{ hashFiles('Makefile') }}-${{ env.TEMPLATES_VERSION }}
key: ${{env.DEPENDENCY_CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
- name: Install dependencies
if: steps.dependency-cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
env:
Expand Down Expand Up @@ -807,7 +806,7 @@ jobs:
path: |
${{ env.pythonLocation }}
renku/templates
key: ${{ env.DEPENDENCY_CACHE_PREFIX }}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}-${{ hashFiles('Makefile') }}-${{ env.TEMPLATES_VERSION }}
key: ${{env.DEPENDENCY_CACHE_PREFIX}}-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{hashFiles('poetry.lock')}}-${{hashFiles('Makefile')}}
- name: Install dependencies
if: steps.dependency-cache.outputs.cache-hit != 'true' || 'refs/heads/master' == github.ref || 'refs/heads/develop' == github.ref || startsWith(github.ref, 'refs/tags/')
env:
Expand Down
24 changes: 12 additions & 12 deletions renku/ui/cli/init.py
Expand Up @@ -69,9 +69,9 @@
... OK
INDEX ID DESCRIPTION PARAMETERS
----- ------ -------------------------- ----------------------
1 python Basic Python Project:[...] description: proj[...]
2 R Basic R Project: The [...] description: proj[...]
----- -------------- -------------------------- ----------------------
1 python-minimal Basic Python Project:[...] description: proj[...]
2 R-minimal Basic R Project: The [...] description: proj[...]
Please choose a template by typing the index:
Expand All @@ -86,7 +86,7 @@
.. code-block:: console
$ renku init --template-id python --parameter \
$ renku init --template-id python-minimal --parameter \
"description"="my new shiny project"
Initializing new Renku repository... OK
Expand All @@ -113,7 +113,7 @@
"@type": "https://schema.org/Organization", \
"https://schema.org/legalName": "ETHZ"}' > metadata.json
$ renku init --template-id python --parameter \
$ renku init --template-id python-minimal --parameter \
"description"="my new shiny project" --metadata metadata.json
Initializing new Renku repository... OK
Expand All @@ -136,13 +136,13 @@
$ echo "FROM python:3.7-alpine" > Dockerfile
$ renku init
INDEX ID PARAMETERS
------- --------- ------------
1 python description
2 R description
3 bioc description
4 julia description
5 minimal
INDEX ID PARAMETERS
------- -------------- ------------
1 python-minimal description
2 R-minimal description
3 bioc-minimal description
4 julia-minimal description
5 minimal
Please choose a template by typing the index: 1
The template requires a value for "description": Test Project
Initializing Git repository...
Expand Down
4 changes: 2 additions & 2 deletions tests/cli/test_init.py
Expand Up @@ -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" in stripped_output
assert "2 R" in stripped_output
assert "1 python-minimal" in stripped_output
assert "2 R-minimal" in stripped_output


def test_init(isolated_runner, project_init):
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/test_migrate.py
Expand Up @@ -142,7 +142,7 @@ def test_migrations_runs(isolated_runner, old_project):
assert "Successfully applied" in result.output
assert "OK" in result.output

result = isolated_runner.invoke(cli, ["migrate", "--skip-template-update"])
result = isolated_runner.invoke(cli, ["migrate"])
assert 0 == result.exit_code, format_result_exception(result)
assert "No migrations required." in result.output

Expand Down
51 changes: 27 additions & 24 deletions tests/cli/test_template.py
Expand Up @@ -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" in result.output
assert "python-minimal" in result.output
finally:
sys.argv = argv

Expand All @@ -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" in result.output
assert "julia" in result.output
assert "python-minimal" in result.output
assert "julia-minimal" 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" in result.output
assert "julia" in result.output
assert "python-minimal" in result.output
assert "julia-minimal" in result.output
finally:
sys.argv = argv

Expand All @@ -81,7 +81,7 @@ def test_template_show(isolated_runner):
sys.argv = command

try:
result = isolated_runner.invoke(cli, command + ["R"])
result = isolated_runner.invoke(cli, command + ["R-minimal"])

assert 0 == result.exit_code, format_result_exception(result)
assert re.search("^Name: Basic R (.*) Project$", result.output, re.MULTILINE) is not None
Expand Down Expand Up @@ -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" == project_context.project.template_metadata.template_id
assert "python-minimal" == 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"])
result = runner.invoke(cli, ["template", "set", "--force", "R-minimal"])

assert 0 == result.exit_code, format_result_exception(result)
with with_injection():
assert "R" == project_context.project.template_metadata.template_id
assert "R-minimal" == 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

Expand All @@ -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"])
result = runner.invoke(cli, ["template", "set", "--force", "R-minimal"])

assert 0 == result.exit_code, format_result_exception(result)
with with_injection():
assert "R" == project_context.project.template_metadata.template_id
assert "R-minimal" == 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)

Expand All @@ -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", "-i"], input=f"{overwrite}\n" * 420)
result = runner.invoke(cli, ["template", "set", "-f", "R-minimal", "-i"], input=f"{overwrite}\n" * 420)

assert 0 == result.exit_code, format_result_exception(result)
with with_injection():
assert "R" == project_context.project.template_metadata.template_id
assert "R-minimal" == 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)

Expand All @@ -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", "--interactive"], input="y\n" * 420)
result = runner.invoke(cli, ["template", "set", "-f", "R-minimal", "--interactive"], input="y\n" * 420)

assert 0 == result.exit_code, format_result_exception(result)

Expand All @@ -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"]).exit_code
assert 0 == runner.invoke(cli, ["template", "set", "python-minimal"]).exit_code

assert f"RENKU_VERSION={__version__}" in project_context.docker_path.read_text()

Expand All @@ -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", "--dry-run"])
result = runner.invoke(cli, ["template", "set", "-f", "R-minimal", "--dry-run"])

assert 0 == result.exit_code, format_result_exception(result)
assert not project.repository.is_dirty()
Expand All @@ -232,23 +232,25 @@ 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", "-s", TEMPLATES_URL, "-r", "0.4.0", "-p", "description=fixed-version"]
cli,
["template", "set", "-f", "python-minimal", "-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" == project_context.project.template_metadata.template_id
assert "0.4.0" == project_context.project.template_metadata.template_ref
assert "5df0ae30086e6ac46ff2b1cc038f3e2dfcf74962" == project_context.project.template_metadata.template_version
assert "python-minimal" == 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

result = runner.invoke(cli, ["template", "update"])

assert 0 == result.exit_code, format_result_exception(result)
assert "Template is up-to-date" not in result.output
with with_injection():
assert "python" == project_context.project.template_metadata.template_id
assert Version(project_context.project.template_metadata.template_ref) > Version("0.4.0")
assert "5df0ae30086e6ac46ff2b1cc038f3e2dfcf74962" != project_context.project.template_metadata.template_version
assert "python-minimal" == 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

result = runner.invoke(cli, ["template", "update"])

Expand Down Expand Up @@ -282,7 +284,8 @@ 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", "-s", TEMPLATES_URL, "-r", "0.4.0", "-p", "description=fixed-version"],
["template", "set", "-f", "python-minimal", "-s", TEMPLATES_URL, "-r", "0.3.2"]
+ ["-p", "description=fixed-version"],
)

assert 0 == result.exit_code, format_result_exception(result)
Expand Down

0 comments on commit e1960c1

Please sign in to comment.