Add support of symbolic links as entrypoint of function. #1518
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
If the entrypoint specified in Function is not a regular file but a symbolic link to a python file, the upload to the cluster will be incomplete and execution of the entrypoint will fail. This PR provides support to run with symbolic links/hardlinks in addition to real file.
Details and comments
Creates
source_files
directory and put the following 2 files. One is real file, another is symbolic linked file.And then, creates an instance of QiskitFunction with
pattern_with_parallel_workflow.py
as entrypoint.Above invocation and subsequent upload() are succeeded, but the following error is occurred when running this function.
This is because of this implementation.
Symbolic link target(=content) will not be included in the archive file. As result, it will not be available in the cluster side.
TarFile provides the solution for this case. The content of the target files can be added to the archive if
dereference=True
.with tarfile.open(artifact_file_path, "w", dereference=True) as tar:
This PR will change above 1 line to support both regular file and symbolic/hard links.