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

Docs/readme #40

Merged
merged 28 commits into from
Jan 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
91dd65d
more or less basic structure
mdip226 Nov 11, 2021
507de49
random error
mdip226 Nov 11, 2021
06093d8
docker stuff and comments
mdip226 Nov 11, 2021
3d99740
formatting
mdip226 Nov 11, 2021
724ca5e
clarifying instructions
mdip226 Nov 18, 2021
7ca2b0f
needs a few touch ups
mdip226 Nov 18, 2021
6a1aca0
example notebook
mdip226 Nov 19, 2021
5f7aa47
note to self
mdip226 Nov 19, 2021
d9f1590
forgot to save
mdip226 Nov 19, 2021
8e5fa87
a few little additions
mdip226 Nov 19, 2021
85ef197
edit
mdip226 Nov 19, 2021
dff1012
quicksave
mdip226 Nov 19, 2021
edbba54
Update README.md
briandrawert Nov 19, 2021
86ec4c7
Merge branch 'dev' of github.com:StochSS/stochss-compute into docs/re…
mdip226 Nov 21, 2021
ba416c8
accounts for user-provided dask cluster rather than automatic instant…
mdip226 Nov 21, 2021
f9b6f6a
`resolve()` instead of `wait()`
mdip226 Nov 21, 2021
446c329
preview not working
mdip226 Dec 10, 2021
73dbeac
simplify instructions
mdip226 Dec 10, 2021
0ce9384
re-arrange
mdip226 Dec 10, 2021
0d459bf
remove minikube until later release and remove redundant example
mdip226 Dec 10, 2021
50bfd24
remove old outputs
mdip226 Dec 10, 2021
6687324
remove reference to not-fully-implemented feature
mdip226 Dec 10, 2021
01e1f55
edit type
mdip226 Dec 10, 2021
a26bc8a
grammar
mdip226 Dec 10, 2021
0c47ed5
Update README.md
briandrawert Dec 15, 2021
b1108d5
Merge branch 'docs/readme' into docs/readme-bd
mdip226 Dec 15, 2021
62463e8
Merge pull request #59 from StochSS/docs/readme-bd
mdip226 Dec 15, 2021
e22392c
Merge branch 'dev' of github.com:StochSS/stochss-compute into docs/re…
briandrawert Jan 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
121 changes: 66 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,83 +1,90 @@
## Installation
# StochSS-Compute

#### Docker

The easiest way to get stochss-compute running is with docker. Clone the repository and run the following in the root directory:
With StochSS-Compute, you can run GillesPy2 simulations on your own server. Results are cached and anonymized, so you
can easily save and recall previous simulations.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would replace this with something for generic (as GillesPy2 is just the start). Maybe something like this "A distributed compute delegation server for the StochSS family of stochastic simulators."?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was gonna do that but then I just figured to wait until that's fully implemented

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

but yeah, i agree with what you said


## Example Quick Start
First, clone the repository.
```
docker-compose up --build
git clone https://github.com/StochSS/stochss-compute.git
cd stochss-compute
```
#### Minikube
- first requires `minikube`, `docker`, and `kubectl` to be installed. Then:
- If you are unfamiliar with python virtual environments, read this [documentation](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/#creating-a-virtual-environment) first.
- Note that you will have to activate your venv every time you run stochSS-compute, as well as for your dask scheduler and each of its workers.
- The following will set up the `dask-scheduler`, one `dask-worker`, the backend api server, and launch an example `jupyter` notebook.
- Each of these must be run in separate terminal windows in the main `stochss-compute` directory.
- Just copy and paste!
```
minikube start
cd into kubernetes directory
kubectl apply -f api_deployment.yaml
minikube dashboard
# Terminal 1
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
dask-scheduler
```
- Now, wait for the stochss-compute container to be created.

From here, there are two ways to access the cluster.

##### To set up local access:
`minikube service --url stochss-compute-service`
- exposes external IP (on EKS or otherwise this is handled by your cloud provider)
- use this host and IP when calling ComputeServer()
- first time will be slow because the dask containers have to start up

##### To use ngrok to set up public access (ngrok.com to sign up for a free account and download/install):
```
url=$(minikube service --url stochss-compute-service)
ngrok http $url
# Terminal 2
source venv/bin/activate
dask-worker localhost:8786
```
- use this URL when calling ComputeServer()

#### Manually

Ensure that the following dependencies are installed with your package manager of choice:

- `python-poetry`
- `redis`

Clone the repository and navigate into the new `stochss-compute` directory. Once inside, execute the following command to install the Python dependencies:

```
poetry install
# Terminal 3
source venv/bin/activate
python3 app.py
```

And to activate the new virtual environment:
- Stochss-compute is now running on localhost:1234.
<!-- - Dask compute cluster configuration parameters can be passed to `app.py`, see the [documentation](https://github.com/StochSS/stochss-compute/blob/dev/stochss_compute/api/delegate/dask_delegate.py#L20). -->

mdip226 marked this conversation as resolved.
Show resolved Hide resolved
```
poetry shell
# Terminal 4
source venv/bin/activate
jupyter notebook --port=9999
```
- This notebook will show you how to use StochSS-compute.
- Jupyter should then launch automatically, where you can then navigate to the examples directory and open up StartHere.ipynb.
- If not, copy and paste the following URL into your web browser:
`http://localhost:9999/notebooks/examples/StartHere.ipynb`
#### Docker

Once complete, both `celery` and `redis` need to be running.

```
celery -A stochss_compute.api worker -l INFO
```
An alternative installation to the above method is to use docker. We host an image on docker hub you can download and use simply by running the following line.

`redis` can be run in several ways. If you prefer a `systemd` daemon:

```
sudo systemctl start redis
docker run -p 1234:1234 mdip226/stochss-compute:latest
```

Otherwise:
- The `-p` flag publishes the container's exposed port on the host computer, as in `-p <hostPort>:<containerPort>`
- Stochss-compute is now running on localhost:1234.

<!-- #### Minikube
- A third usage of StochSS compute it to use it with "Minikube", which is part of [Kubernetes](https://kubernetes.io/).
- Requires `minikube`, `docker`, and `kubectl` to be installed. Then:
```
redis-server
minikube start
cd into kubernetes directory
kubectl apply -f api_deployment.yaml
minikube dashboard
```
- Now, wait for the stochss-compute container to be created.

Finally, start the stochss-compute server.
- From here, there are two ways to access the cluster. -->

<!-- ##### To set up local access:
`minikube service --url stochss-compute-service`
- exposes external IP (on EKS or otherwise this is handled by your cloud provider)
- use this host and IP when calling ComputeServer()
- first time will be slow because the dask containers have to start up

##### To use ngrok to set up public access (ngrok.com to sign up for a free account and download/install):
```
poetry run stochss-compute
url=$(minikube service --url stochss-compute-service)
ngrok http $url
```
- use this URL when calling ComputeServer() -->


## Usage
<!-- ## Usage

Simulations are run on stochss-compute via Jupyter notebooks.
- The easiest way to run stochss-compute simulations is via Jupyter notebooks:

```python
import numpy, gillespy2
Expand Down Expand Up @@ -118,9 +125,13 @@ class ToggleSwitch(gillespy2.Model):
# Instantiate a new instance of the model.
model = ToggleSwitch()

# Run the model on a stochss-compute server instance running on localhost.
results = RemoteSimulation.on(ComputeServer("127.0.0.1", port=1234).with_model(model).run()
# Run the model on a stochss-compute server instance running on localhost.
# The default port is 1234, but will depend on how you choose to set it up.
results = RemoteSimulation.on(ComputeServer("127.0.0.1", port=1234)).with_model(model).run()

# Wait for the simulation to finish.
results.wait()
mdip226 marked this conversation as resolved.
Show resolved Hide resolved

# Plot the results.
results.plot()
```
``` -->
117 changes: 66 additions & 51 deletions examples/StartHere.ipynb

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions stochss_compute/remote_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,9 @@ def resolve(self) -> Results:
return results

def cancel(self):
"""
Cancels the remote job.
"""
# TODO
stop_response = self.server.post(Endpoint.JOB, f"/{self.result_id}/stop")