Skip to content

Commit a762587

Browse files
committed
Merge branch 'main' into readme
2 parents 1eeda2d + eaab27c commit a762587

File tree

6 files changed

+30
-9
lines changed

6 files changed

+30
-9
lines changed

.env.sample

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
schema=<schema>
2+
uri=<uri>

.github/workflows/image.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ jobs:
1515
with:
1616
image: 'hub.opensciencegrid.org/macrostrat/macrostrat-xdd'
1717
context: macrostrat_db_insertion
18-
file: macrostrat_db_insertion/Dockerfile
18+
file: macrostrat_db_insertion/Dockerfile

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,15 @@ The API endpoint is a Flask server that uses SQLAlchemy to verify the input data
5656
The code for the server can be found in the `macrostrat_db_insertion` directory. We have provided a docker container that contains all of the necessary dependencies which you can setup using:
5757
```
5858
$ cd macrostrat_db_insertion
59-
$ export CURRENT_DIR=`pwd`
60-
$ docker build -t db_insert:latest .
61-
$ docker run -d -v $CURRENT_DIR:/working_dir/ --name=db_insert --entrypoint /bin/bash -p 9543:9543 db_insert:latest -c "sleep infinity"
62-
$ docker exec -it db_insert bash
59+
$ make build
6360
$ conda activate db_insert_env
6461
$ pkill -9 -f "server"
6562
$ export PYTHONPATH="${PYTHONPATH}:/working_dir"
6663
```
6764

6865
Then you can launch the server using:
6966
```
70-
$ python3 -u server.py &> server_requests.log &
67+
$ python3 -u -m macrostrat_db_insertion.server &> server_requests.log &
7168
```
7269

7370
which will launch the server on port `9543` as a background process. Note that to properly launch the server, the environment variables `uri`, and `schema` must be set to the proper values so that the server can properly communicate

macrostrat_db_insertion/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ RUN source ~/.bashrc
2020

2121
WORKDIR /app
2222

23+
# Accept conda terms of service
24+
RUN conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main && \
25+
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r
26+
2327
# Create and activate conda environment
2428
COPY environment.yml environment.yml
2529
RUN conda env create -f environment.yml

macrostrat_db_insertion/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
build:
2+
@export CURRENT_DIR=$$(pwd); \
3+
docker rm -f db_insert 2>/dev/null || true; \
4+
docker build -t db_insert:latest .; \
5+
docker run -d \
6+
-v $$CURRENT_DIR:/working_dir/ \
7+
--env-file $$CURRENT_DIR/.env \
8+
--name=db_insert \
9+
--entrypoint /bin/bash \
10+
-p 9543:9543 \
11+
db_insert:latest \
12+
-c "sleep infinity"; \
13+
docker exec -it db_insert bash

macrostrat_db_insertion/server.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ def process_user_feedback_input_request(request_data, session):
921921
if not success:
922922
return success, err_msg
923923

924-
return True, None
924+
return True, request_additional_data["internal_run_id"]
925925

926926
# Opentially take in user id
927927
@app.post("/record_run")
@@ -931,7 +931,6 @@ async def record_run(
931931
user_id: str | None = Depends(get_user_id),
932932
session: Session = Depends(get_session)
933933
):
934-
935934
if not user_has_access:
936935
raise HTTPException(status_code=403, detail="User does not have access to record run")
937936

@@ -952,8 +951,14 @@ async def record_run(
952951
print("Returning error message", error_msg)
953952
raise HTTPException(status_code=400, detail=error_msg)
954953

955-
return JSONResponse(content={"success": "Successfully processed the run"})
954+
table_id = error_msg
956955

956+
return JSONResponse(content={
957+
"success": "Successfully processed the run",
958+
"data": {
959+
"table_id": str(table_id)
960+
}
961+
})
957962

958963
@app.get("/health")
959964
async def health(

0 commit comments

Comments
 (0)