-
Notifications
You must be signed in to change notification settings - Fork 4
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
#492 #493
#492 #493
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #493 +/- ##
==========================================
- Coverage 75.50% 74.06% -1.45%
==========================================
Files 55 56 +1
Lines 3695 4288 +593
==========================================
+ Hits 2790 3176 +386
- Misses 905 1112 +207 ☔ View full report in Codecov by Sentry. |
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.
This is a solid start, good job getting Jupyter running from inside Singularity/Apptainer. The biggest issue to address is making sure that the user can run this command from outside the Garden repo
Singularity.def
Outdated
|
||
%startscript | ||
|
||
exec /bin/bash -c "jupyter notebook --notebook-dir=/notebooks --ip 0.0.0.0 --no-browser --allow-root" |
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.
Why do we need allow-root
here?
try: | ||
# Ensure the definition file exists | ||
if not os.path.isfile(definition_file): | ||
logger.error(f"Definition file {definition_file} not found.") |
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.
Does this approach rely on the user being in the root directory of the project where Singularity.def
is? Let's make sure the user can run this command in any directory.
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.
Fixed
# Step 3: Build the Apptainer container | ||
build_command = ["apptainer", "build", container_image, definition_file] | ||
subprocess.run(build_command, check=True) | ||
logger.info("Apptainer container built successfully.") |
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.
Does this command give you a way to reuse an image if you've already built it?
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, I add a rerun command
Singularity.def
Outdated
@@ -0,0 +1,25 @@ | |||
Bootstrap: docker |
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.
This sort of file shouldn't live at the root of the project. Our Docker building script is in scripts
. Can you move this there or create a new appropriate directory for it?
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.
Fixed
notebooks/notebooks.md
Outdated
@@ -0,0 +1 @@ | |||
Place to store notebooks |
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.
If the intent is that this is for users' notebook files, it doesn't belong in the project repository.
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.
Deleted
tmp/tmp.md
Outdated
@@ -0,0 +1 @@ | |||
Place to store temporary file |
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.
Similarly, a tmp directory for the user should not be committed to the project.
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.
Deleted
garden_ai/app/hpc_notebook.py
Outdated
"notebook", | ||
"--no-browser", | ||
"--ip=0.0.0.0", | ||
"--allow-root", |
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.
It looks like this command will use the default Jupyter port. I'd recommend reusing the find_available_port
helper to avoid the (likely) scenario of colliding with another user on the login node using the default Jupyter port
typer.echo("🚧🌱🚧 Failed to start Jupyter Notebook 🚧🌱🚧") | ||
except Exception as e: | ||
logger.error(f"An error occurred: {e}") | ||
typer.echo("🚧🌱🚧 An unexpected error occurred 🚧🌱🚧") |
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.
How should the user shut down their Singularity container when they're done? It's ok to not build in really robust cleanup handling right now, but ideally we could handle the happy path of the user hitting ctrl-c. Or at least we should print instructions to the user for how they can manually end their session.
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.
@JoeyC12 Can you address this question?
… Move definition file to scripts and use absolute path.
garden_ai/app/hpc_notebook.py
Outdated
): | ||
root = os.path.dirname(os.path.abspath(__file__)) | ||
root = os.path.dirname(root) | ||
root = os.path.dirname(root) |
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.
I think saving the sif file next to where the user has installed the Python code is pretty surprising. That will make it hard to find and clean up. Can we instead save it by default in the directory where the user ran the garden-ai command? (Maybe with an option to specify a different directory?)
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.
Also it looks like there are some repeated lines here
garden_ai/app/hpc_notebook.py
Outdated
|
||
script_dir = os.path.dirname(os.path.abspath(__file__)) | ||
script_dir = os.path.dirname(script_dir) | ||
script_dir = os.path.dirname(script_dir) |
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.
typo?
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.
script_dir = os.path.dirname(script_dir) goes to parent directory. I am locating the definition file here.
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.
I see. This is pretty unintuitive for a reader of this code. Can you either find a different way to express this or add a comment explaining this?
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.
Friendly ping on this comment @JoeyC12
typer.echo("🚧🌱🚧 Failed to start Jupyter Notebook 🚧🌱🚧") | ||
except Exception as e: | ||
logger.error(f"An error occurred: {e}") | ||
typer.echo("🚧🌱🚧 An unexpected error occurred 🚧🌱🚧") |
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.
@JoeyC12 Can you address this question?
garden_ai/app/hpc_notebook.py
Outdated
|
||
tmp_dir = os.path.join(working_directory, "tmp") | ||
if os.path.exists(tmp_dir): | ||
shutil.rmtree(tmp_dir) |
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.
I think the Python tempfile utils always return different filenames, so I don't think this cleanup step does much in practice
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.
Deleted this line
garden_ai/app/hpc_notebook.py
Outdated
os.makedirs(notebooks_dir) | ||
|
||
# Step 1: Create temporary directory if it doesn't exist | ||
working_directory = tempfile.mkdtemp() |
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.
I think it would be least surprising if we make the singularity working directory the user's current working directory. (ie, where they executed garden-ai
).
If you want to go with temp dirs instead, we'll need to clean it up properly. (ie, use the TemporaryDirectory context manager)
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.
@JoeyC12 Can you address this?
…when user hit control-c
…when user hit control-c
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.
Thanks for getting these edits in! This looks good to merge
#492
‘garden-ai hpc-notebook start --working-directory$(pwd)/tmp --notebooks-dir $ (pwd)/notebooks’ starts a Jupyter notebook in an Apptainer Container.
📚 Documentation preview 📚: https://garden-ai--493.org.readthedocs.build/en/493/