Skip to content

Commit

Permalink
add attempt to render notebook
Browse files Browse the repository at this point in the history
note that the notebook has bugs (pun intended) so the render
is commented out for now.

Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed Mar 15, 2023
1 parent 9def1a6 commit 00a1c74
Show file tree
Hide file tree
Showing 5 changed files with 4,298 additions and 20 deletions.
15 changes: 14 additions & 1 deletion weave-demos/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,26 @@ RUN DEBIAN_FRONTEND="noninteractive" apt-get -y install \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# This is needed for the notebook render
RUN git clone https://github.com/LLNL/PyDV /tmp/pydv && \
cd /tmp/pydv/ && \
python3 -m pip install .

# Wrappers to ensure we source the mamba environment!
RUN git clone --depth 1 https://github.com/LLNL/weave-demos /workflow
WORKDIR /workflow/ball_bounce
COPY ./scripts/setup.sh /setup.sh
COPY ./ball_bounce_suite_flux.yaml ./ball_bounce_suite_flux.yaml
RUN /bin/bash /setup.sh && python3 -m pip install -r requirements.txt && \
# The workflow expects to find python
ln -s /usr/bin/python3 /usr/bin/python
ln -s /usr/bin/python3 /usr/bin/python && \
python3 -m pip install jut && \
python3 -m pip install typing-extensions --upgrade && \
python3 -m pip install ipympl && \
python3 -m pip install pydv

# Temporary fix for
# https://github.com/LLNL/PyDV/issues/275
COPY ./scripts/pydvpy.py /usr/local/lib/python3.8/dist-packages/pydv/pydvpy.py
COPY ./scripts/visualization.ipynb ./visualization.ipynb
EXPOSE 8888
47 changes: 30 additions & 17 deletions weave-demos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,26 @@ $ python /workflow/ball_bounce/./ball_bounce.py output.dsv 45 37 19 -3 3 1 0.5 1

It generated an output.dsv almost immediately. We could likely adjust the simulation parameters for the calculation.

## Quick Start with Flux

We can basically run the workflow to run the simulation, generate a (partial) notebook (note there were bugs with the
final visualization) and then copy it over to view it locally.

```bash
$ docker run --entrypoint bash --rm --name demo -it demos
$ flux start --test-size=4
$ maestro run ball_bounce_suite_flux.yaml --pgen pgen.py -y
```

**Important** the current notebook has bugs (and is commented out) but if someone can fix them,
we should be able to uncomment the step and copy it over to our local machine as follows:

```bash
$ docker cp demo:/workflow/ball_bounce/render.ipynb ./scripts/render.ipynb
```

If we were doing this with the operator, we would copy this result to a bound volume to save (and maybe some of the simulation data).

## Run with Flux

I then wanted to run with Flux. Start an instance:
Expand Down Expand Up @@ -106,9 +126,8 @@ The content of each looks like:
$(LAUNCHER) python /workflow/ball_bounce/./ball_bounce.py output.dsv 73 48 11 1 4 5 0.5 100 dcb980 9
```

I'm not sure I did that correctly - I saw [an example for LAUNCHER](https://github.com/LLNL/maestrowf/blob/51056ccfe279495a329036597510d1489dd0c1b1/samples/lulesh/lulesh_sample1_unix_flux.yaml#L19)
and mimicked it, but I'm skeptical because I don't see any jobs in the `flux jobs -a`. To test, I ran the command manually with flux submit, and I saw the jobs! So I changed `${LAUNCHER}`
in the flux YAML to just be flux submit, and that seemed to (instead) run everything with Flux.
I saw [an example for LAUNCHER](https://github.com/LLNL/maestrowf/blob/51056ccfe279495a329036597510d1489dd0c1b1/samples/lulesh/lulesh_sample1_unix_flux.yaml#L19)
and mimicked it to make a variable named launcher that is basically an alias for `flux submit`.

```bash
flux jobs -a
Expand All @@ -130,24 +149,18 @@ flux jobs -a
ƒ41BYo11Z root python CD 1 1 0.059s 10864fec333d
```
Note that you'll get callback errors because flux is running as root. We can likely get around this running in the operator.
When everything is done, you'll see an output.sqlite database in the root directory where you ran maestro, and a render.ipynb
in the output path.

A high level note - given that Maestro doesn't stay attached to the job, if we are running via the operator the "run as a command" single-user
mode likely won't work - we would need to run via an interactive job, and determine (on our own) when the workflow is done.


## Run with Flux + Notebooks

TBA! I need to test this.
We can likely use the presence of this file.

```bash
$ docker run --entrypoint bash -p 8000:8000 -it demos
# ls
```

Here is a more "quick start" (not tested yet)

```bash
$ flux start --test-size=4
$ maestro run ball_bounce_suite_flux.yaml --pgen pgen.py -y
# Living dangerously!
$ jupyter notebook --allow-root --no-browser visualization.ipynb
```console
01_baseline_simulation 04_manage_data README.md ball_bounce_suite.yaml output requirements.txt visualization.ipynb
02_uncertainty_bounds 05_post-process_data __pycache__ ball_bounce_suite_flux.yaml output.sqlite setup.sh
03_simulation_ensembles 06_surrogate_model ball_bounce.py dsv_to_sina.py pgen.py teardown.sh
```
14 changes: 12 additions & 2 deletions weave-demos/ball_bounce_suite_flux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env:
SIM_SCRIPT_PATH: ./ball_bounce.py
PROCESS_SCRIPT_PATH: ./dsv_to_sina.py
OUTPUT_DS_PATH: ./output.sqlite
LAUNCHER: flux submit

batch:
type : flux
Expand All @@ -18,11 +19,20 @@ study:
run:
# Note that flux submit before (should be?) $(LAUNCHER) but I didn't see that worked - I think likely it needs a different submit command / setup
cmd: |
flux submit python $(SPECROOT)/$(SIM_SCRIPT_PATH) output.dsv $(X_POS_INITIAL) $(Y_POS_INITIAL) $(Z_POS_INITIAL) $(X_VEL_INITIAL) $(Y_VEL_INITIAL) $(Z_VEL_INITIAL) $(GRAVITY) $(BOX_SIDE_LENGTH) $(GROUP_ID) $(RUN_ID)
$(LAUNCHER) python $(SPECROOT)/$(SIM_SCRIPT_PATH) output.dsv $(X_POS_INITIAL) $(Y_POS_INITIAL) $(Z_POS_INITIAL) $(X_VEL_INITIAL) $(Y_VEL_INITIAL) $(Z_VEL_INITIAL) $(GRAVITY) $(BOX_SIDE_LENGTH) $(GROUP_ID) $(RUN_ID)
- name: ingest-ball-bounce
description: Ingest the outputs from the previous step
run:
cmd: |
flux submit python $(SPECROOT)/$(PROCESS_SCRIPT_PATH) ../run-ball-bounce $(SPECROOT)/$(OUTPUT_DS_PATH)
$(LAUNCHER) python $(SPECROOT)/$(PROCESS_SCRIPT_PATH) ../run-ball-bounce $(SPECROOT)/$(OUTPUT_DS_PATH)
depends: [run-ball-bounce_*]

# This notebook has bugs - but when fixed this will work
# - name: plot-ball-bounce
# description: Generate the notebook that shows something interesting!
# run:
# I hard coded the path because I was lazy - not ideal
# cmd: |
# $(LAUNCHER) jupyter nbconvert --to notebook --execute /workflow/ball_bounce/visualization.ipynb --output=/workflow/ball_bounce/render.ipynb --ExecutePreprocessor.timeout=-1
# depends: [ingest-ball-bounce]

0 comments on commit 00a1c74

Please sign in to comment.