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

Refactor into single image #25

Merged
merged 10 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ LANG = en_US.utf-8
PYTHON = $(shell which python3 || which python)
DOCKER = $(shell which docker)
DOCKER_COMPOSE = $(shell which docker || echo "$(DOCKER) compose")
DOCKER_COMPOSE_YAML = docker/docker-compose.yaml
export LANG

# Initializes submodules and copies environment file sample to env file.
Expand All @@ -14,27 +15,32 @@ init:
# Environment file copy
envfile:
ifeq ($(wildcard envfile),)
cp api.env.sample api.env; \
cp env.sample .env; \
echo -e "\nDon't forget to update 'envfile' with all your secrets!";
endif

# Turn project on
.PHONY:up
up:docker-compose.yaml
$(DOCKER_COMPOSE) compose up -d
up:docker/docker-compose.yaml
$(DOCKER_COMPOSE) compose --file $(DOCKER_COMPOSE_YAML) up -d

# Rebuild all containers and turn project on
.PHONY:up-rebuild
up-rebuild:docker-compose.yaml
$(DOCKER_COMPOSE) compose up --build -d
up-rebuild:$(DOCKER_COMPOSE_YAML)
$(DOCKER_COMPOSE) compose --file $(DOCKER_COMPOSE_YAML) up --build -d

# Rebuild the docker image from scratch
.PHONY:up-rebuild
force-rebuild:$(DOCKER_COMPOSE_YAML)
$(DOCKER_COMPOSE) compose --file $(DOCKER_COMPOSE_YAML) build --no-cache

# Turn project off
.PHONY:down
down:docker-compose.yaml
$(DOCKER_COMPOSE) compose down
down:$(DOCKER_COMPOSE_YAML)
$(DOCKER_COMPOSE) compose --file $(DOCKER_COMPOSE_YAML) down

# Restart project
.PHONY:restart
restart:docker-compose.yaml
restart:$(DOCKER_COMPOSE_YAML)
make down && make up

24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[![Build and Publish](https://github.com/DARPA-ASKEM/service-template/actions/workflows/publish.yaml/badge.svg?event=push)](https://github.com/DARPA-ASKEM/service-template/actions/workflows/publish.yaml)
# PyCIEMSS Simulation Service

# PyCIEMSS Simulation API
The service is a light wrapper service around [pyciemss](https://github.com/ciemss/pyciemss).
Both a FastAPI and RQ tasks are provided so jobs can be run asynchronously for long periods
of time. The service must also [conform to this spec](https://github.com/DARPA-ASKEM/simulation-api-spec).

## Startup

Expand All @@ -12,11 +14,23 @@ in order to pull the PyCIEMSS repository in as a submodule and set up the enviro

`make up`

to start the containers and the API. The API url will be `http://localhost:8010` without any additional configuration changes.
to start the containers and the API. The API url will be `http://localhost:8010` by default

## Endpoints
## Notes
To start an RQ worker, use the following command in the container (default)
```
rq worker --url redis://$REDIS_HOST:$REDIS_PORT high default low
```

WIP
To start the API, use the following command in the container
```
uvicorn server:app --reload --host 0.0.0.0 --port 8000
```

Every operation saves 3 files to S3
- `result.csv`
- `eval.csv`
- `visualization.json`


## License
Expand Down
15 changes: 0 additions & 15 deletions api/Dockerfile

This file was deleted.

226 changes: 0 additions & 226 deletions api/server.py

This file was deleted.

Loading
Loading