-
Notifications
You must be signed in to change notification settings - Fork 0
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
#273: Added jupyterenv/bin to environment variable PATH inside the Entrypoint #314
Merged
Merged
Changes from 11 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
0cfbceb
#273: Added jupyterenv/bin to evironment variable PATH inside the Do…
ckunki 5da00cd
Fixed path variable
ckunki 9ae60e5
Infer previous value of PATH variable from container
ckunki b07d657
Fixed typo in changes file
ckunki 34938da
Simplified implementation
ckunki 0919b2b
Added unit test for DssDockerImage._path()
ckunki ef5655e
make virtualenv/bin prefix of PATH rather than suffix
ckunki c3b7a43
Addded parameter --venv to entrypoint
ckunki 9fcf597
Prepare moving PATH to entrypoint
ckunki 61c4899
Merge branch 'feature/#273-2-venv' into feature/#273-Add_jupyterenv_b…
ckunki 07be2bf
Moved modifying PATH to entrypoint.py
ckunki 32bb531
Fixed review finding: removed unused method command_with_venv()
ckunki f8b6545
Updated changes file
ckunki 534eaeb
Fixed broken link in documentation.
ckunki 29167f8
Update PTB actions to @v4
ckunki 37fb4e6
[CodeBuild]
ckunki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,10 @@ def arg_parser(): | |
"--notebooks", type=Path, | ||
help="destination location for notebook files to copy", | ||
) | ||
parser.add_argument( | ||
"--venv", type=Path, metavar="<PATH-TO-VIRTUAL-ENVIRONMENT>", | ||
help="Prepend subdirectory bin to environment variable PATH before starting Jupyter server", | ||
) | ||
parser.add_argument( | ||
"--jupyter-server", metavar="<PATH-TO-JUPYTER-BINARY>", | ||
help="start server for Jupyter notebooks", | ||
|
@@ -75,6 +79,11 @@ def arg_parser(): | |
return parser | ||
|
||
|
||
def command_with_venv(venv_activate: Path, command: List[str]) -> List[str]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not needed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah - left over from an experiment. |
||
bash_cmd = [ "source", str(venv_activate), ";" ] + command | ||
return [ "bash", "-c", " ".join(bash_cmd) ] | ||
|
||
|
||
def start_jupyter_server( | ||
home_directory: str, | ||
binary_path: str, | ||
|
@@ -83,6 +92,7 @@ def start_jupyter_server( | |
logfile: Path, | ||
user: str, | ||
password: str, | ||
venv: Path, | ||
poll_sleep: float = 1, | ||
): | ||
""" | ||
|
@@ -107,6 +117,11 @@ def exit_on_error(rc): | |
|
||
env = os.environ.copy() | ||
env["HOME"] = home_directory | ||
if venv: | ||
venv_bin = str(venv / "bin") | ||
path = env.get("PATH") | ||
env["PATH"] = f"{venv_bin}:{path}" if path else venv_bin | ||
_logger.info(f'Changed environment variable PATH to {env["PATH"]}') | ||
with open(logfile, "w") as f: | ||
p = subprocess.Popen(command_line, stdout=f, stderr=f, env=env) | ||
|
||
|
@@ -350,6 +365,7 @@ def main(): | |
args.jupyter_logfile, | ||
args.user, | ||
args.password, | ||
args.venv, | ||
) | ||
else: | ||
sleep_infinity() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks!
See next push.