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

Create local artifact directory if it does not exist #847

Merged
merged 5 commits into from
Feb 9, 2024

Conversation

mrchtr
Copy link
Contributor

@mrchtr mrchtr commented Feb 7, 2024

This bothers me already for some time. Change the mounting of the local base path in the docker compile. Now a local base path is created.

Copy link
Member

@RobbeSneyders RobbeSneyders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mrchtr, nice of you to pick this up 😛

Comment on lines +142 to +146
def is_remote_path(path: Path) -> bool:
"""Check if the path is remote."""
_path = str(path)
prefixes = set(known_implementations.keys()) - {"local", "file"}
return any(_path.startswith(prefix) for prefix in prefixes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be easier to swap this check and check if it's local instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. The remote prefixes are well defined by the known_implementations. The local paths can be more complex (start with prefix, without prefix, absolute path, relative path, ...). Thought a check for a remote path is easier.

@@ -270,7 +270,7 @@ def test_local_run(mock_docker_installation):
"""Test that the run command works with different arguments."""
args = argparse.Namespace(
local=True,
ref="some/path",
ref=__name__,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we using __name__ here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand completely why the tests have worked before. The actual module contains a test pipeline which is used as reference for the test cases. __name__ makes more sense here.
However, I would cleanup the test cases as well. I think we can extract some fixtures here and make it more robust.

tests/pipeline/test_runner.py Outdated Show resolved Hide resolved
@@ -168,6 +169,7 @@ def test_docker_compiler(setup_pipeline, tmp_path_factory):
example_dir, pipeline, _ = setup_pipeline
compiler = DockerCompiler()
with tmp_path_factory.mktemp("temp") as fn:
pipeline.base_path = str(fn)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big fan of this. Can we turn the fixture into a factory function?

See this example from connexion.

Copy link
Contributor Author

@mrchtr mrchtr Feb 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's fine for you I would exclude it here and keep the test as it is. I'll create an separat issue for this. I took a look into the test and I think it would result in a bigger refactoring. It would make indeed sense to have a pipeline factory cause it is needed in several test cases. Not only here in this file.

Copy link
Collaborator

@GeorgesLorre GeorgesLorre Feb 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have code like this that we could reuse more.

eg:

def setup_pipeline(request, tmp_path, monkeypatch):

This is one is even parameterized so you can easily run the same test on multiple pipelines.

@mrchtr mrchtr merged commit ac23862 into main Feb 9, 2024
10 of 11 checks passed
@mrchtr mrchtr deleted the bugfix/local-base-path-creation branch February 9, 2024 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants