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

#89 setup whyis docker container #110

Merged
merged 12 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from 7 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
53 changes: 52 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,56 @@ services:
volumes:
- /app/node_modules
- ./app:/app
redis:
image: "redis:alpine"
command: redis-server
volumes:
- ./mockDB/redis-data:/var/lib/redis
celery:
depends_on:
- redis
- fuseki
volumes:
- ./mockDB/fuseki:/app/run
- ./whyis/materialsmine:/app
command: /opt/venv/bin/celery -A wsgi.celery worker -l INFO -c 4 --uid=nobody --gid=nogroup
environment:
- CHOKIDAR_USEPOLLING=true
build: whyis
celerybeat:
depends_on:
- redis
- fuseki
volumes:
- ./mockDB/fuseki:/app/run
- ./whyis/materialsmine:/app
command: /opt/venv/bin/celery -A wsgi.celery beat -l INFO --uid=nobody --gid=nogroup
environment:
- CHOKIDAR_USEPOLLING=true
build: whyis
fuseki:
command: /opt/venv/bin/fuseki-server --mem /ds #/opt/venv/bin/whyis fuseki
environment:
- CHOKIDAR_USEPOLLING=true
build: whyis
# ports:
# - '3030:3030'
volumes:
- ./materialsmine:/app
- ./whyis/materialsmine:/app
jpmccu marked this conversation as resolved.
Show resolved Hide resolved
whyis:
depends_on:
- redis
- fuseki
stdin_open: true
command: /opt/venv/bin/gunicorn wsgi:application --workers ${WEB_CONCURRENCY:-8} --timeout 90 -b :8000
environment:
- CHOKIDAR_USEPOLLING=true
build: whyis
volumes:
- ./whyis/materialsmine:/app
- ./mockDB/fuseki:/app/run
ports:
- '8000:8000'
volumes:
mockDB:
mockDB:
1 change: 1 addition & 0 deletions mockDB/fuseki-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
whyis init
16 changes: 8 additions & 8 deletions nginx/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ upstream api {
server api:3000;
}

# upstream whyis {
# server whyis:5000;
# }
upstream whyis {
server whyis:8000;
}

server {
listen 80;
Expand All @@ -29,8 +29,8 @@ server {
proxy_pass http://api;
}

# location /whyis {
# rewrite /whyis/(.*) /$1 break;
# proxy_pass http://whyis;
# }
}
location /whyis {
rewrite /whyis/(.*) /$1 break;
proxy_pass http://whyis;
}
}
21 changes: 16 additions & 5 deletions whyis/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
FROM alpine
RUN apk update && apk add --no-cache python3 py3-pip
RUN alias python=python3
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y software-properties-common gcc

RUN apt-get update && apt-get install -y \
python3.8-distutils \
python3.8-dev \
python3-pip \
python3.8-venv \
curl \
libdb5.3-dev \
default-jdk-headless
RUN python3.8 -m venv /opt/venv
RUN /opt/venv/bin/pip install requests>=2.27.1 wheel gunicorn
RUN /opt/venv/bin/pip install whyis==2.0b1 whyis-unit-converter==0.0.2
COPY ./materialsmine /app
WORKDIR '/app'
COPY . .
CMD [ "python3" ]
CMD [ "/bin/bash" ]
21 changes: 15 additions & 6 deletions whyis/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
FROM ubuntu:18.04
RUN apt-get update && apt-get install -y software-properties-common gcc && \
add-apt-repository -y ppa:deadsnakes/ppa
FROM ubuntu:20.04 as dependencies
RUN apt-get update && apt-get install -y software-properties-common gcc

RUN apt-get update && apt-get install -y python3 python3-distutils python3-pip python3-apt curl
WORKDIR '/apps'
CMD [ "/bin/bash" ]
RUN apt-get update && apt-get install -y \
python3.8-distutils \
python3.8-dev \
python3-pip \
python3.8-venv \
curl \
libdb5.3-dev \
default-jdk-headless
RUN python3.8 -m venv /opt/venv
RUN /opt/venv/bin/pip install requests>=2.27.1 wheel gunicorn
RUN /opt/venv/bin/pip install whyis==2.0b1 whyis-unit-converter==0.0.2
WORKDIR '/app'
jpmccu marked this conversation as resolved.
Show resolved Hide resolved
CMD [ "/bin/bash" ]
57 changes: 53 additions & 4 deletions whyis/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,62 @@
version: '3'
services:
web:
stdin_open: true
redis:
image: "redis:alpine"
command: redis-server
volumes:
- ./mockDB/redis-data:/var/lib/redis
celery:
depends_on:
- redis
- fuseki
command: /opt/venv/bin/celery -A wsgi.celery worker -l INFO -c 4 --uid=nobody --gid=nogroup
volumes:
- ./materialsmine:/app
- ./mockDB/fuseki:/app/run
environment:
- CHOKIDAR_USEPOLLING=true
build:
dockerfile: Dockerfile.dev
context: .
celerybeat:
depends_on:
- redis
- fuseki
command: /opt/venv/bin/celery -A wsgi.celery beat -l INFO --uid=nobody --gid=nogroup
volumes:
- ./materialsmine:/app
- ./mockDB/fuseki:/app/run
environment:
- CHOKIDAR_USEPOLLING=true
build:
dockerfile: Dockerfile.dev
context: .
fuseki:
command: /opt/venv/bin/whyis fuseki # ; /opt/venv/bin/fuseki-server --mem /ds
environment:
- CHOKIDAR_USEPOLLING=true
build:
dockerfile: Dockerfile.dev
context: .
ports:
- '3030:3030'
volumes:
- ./materialsmine:/app
- ./mockDB/fuseki:/app/run
whyis:
depends_on:
- redis
- fuseki
stdin_open: true
command: /opt/venv/bin/gunicorn wsgi:application --workers ${WEB_CONCURRENCY:-4} --timeout 90 -b :8000
environment:
- CHOKIDAR_USEPOLLING=true
build:
dockerfile: Dockerfile.dev
context: .
volumes:
- ./materialsmine:/app
- ./mockDB/fuseki:/app/run
ports:
- '8000:8000'
- '5000:5000'
volumes:
- .:/apps
29 changes: 29 additions & 0 deletions whyis/materialsmine/.circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: 2
jobs:
build:
working_directory: /apps/nanomine-graph
docker:
- image: tetherlessworld/whyis:latest
steps:
- checkout
- run:
name: Set permissions
command: chown -R whyis.whyis /apps/nanomine-graph
- run:
name: Install application
command: pip3 install -e .
- run:
name: Install newer version of SETLr
command: |
pip3 uninstall --yes setlr
pip3 install -q git+https://github.com/tetherless-world/setlr.git#egg=setlr
- run:
name: Start the whyis entrypoint (assumes cwd /apps/whyis)
command: cd /apps/whyis && /docker-entrypoint.sh
- run:
name: Run tests
command: cd /apps/whyis && python3 manage.py test --ci
- store_artifacts:
path: /apps/whyis/test-results/py/htmlcov
- store_test_results:
path: /apps/whyis/test-results
112 changes: 112 additions & 0 deletions whyis/materialsmine/ChemDatabase/chemprops_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
[
{
"_id": "O(C1=CC=C(C=C1)C(=O)C2=CC=C(OC3=CC=C(C=C3)[*])C=C2)[*]",
"_stdname": "Poly(ether ether ketone)",
"_abbreviations": [
"PEEK"
],
"_density": 1.29,
"_boc": [
"000060020011012102030000100000000000",
"000020000010000100000000000000000000"
],
"_tradenames": [
"Zeniva",
"KetaSpire"
],
"_synonyms": []
},
{
"_id": " C(C(C1=CC=CC=C1)[*])[*] ",
"_stdname": "Polystyrene",
"_abbreviations": [
"PS"
],
"_density": 1.04,
"_boc": [
"000020000001011101110000200000000000",
"000000000000000100100000000000000000",
"000040020002021200010000200000000000",
"000040020003021200010000300100000000",
"010030001002031100000100210000000000"
],
"_tradenames": [
"Pelaspan",
"Afcolene",
"Aim",
"Amoco",
"Bextrene",
"Carinex",
"Distrene",
"Dylene",
"Edistir",
"Erinoid",
"Fina",
"Fostarene",
"Gedex",
"Hostyren",
"Huntsman PS",
"Lacqrene",
"Ladene",
"Lorkalene",
"Luron",
"Lustran",
"Lustrex",
"Neste PS",
"Polystyrol",
"Restirolo",
"Sicostyrol",
"Sternite",
"Stiroplasto",
"Stymer",
"Styrodur",
"Styron",
"Styvarene",
"Vestyron",
"Polystyrol",
"Polyzote",
"Pyrochek 68"
],
"_synonyms": [
"polyphenylethene",
"poly-1-phenylethylene",
"polyvinylbenzene"
]
},
{
"_id": "N(CCCCCC(=O)[*])[*]",
"_stdname": "Nylon 6",
"_abbreviations": [
"PA 6",
"Nylon 6"
],
"_density": 1.08,
"_boc": [
"000000000001021000000000100000001000",
"100000000000000100000000000000001000",
"000000000001021000000000100000001000",
"302000000002102201010000100000000000",
"100110001001101100000000100000001000",
"301110002001213201000000100000000000",
"303100003001113201000000100000001000",
"303100003001113201000000100000000000",
"201110001001102201000000100000000000",
"302000000002102201010000100000000000",
"100040022002224100010002200100000000"
],
"_tradenames": [
"Perlon",
"Plaskon"
],
"_synonyms": [
"Poly(caprolactam)",
"polyamide 6",
"poly(ω-aminocaproamide)",
"poly(6-aminocaproic acid)",
"poly(ε-aminocaproic acid)",
"poly(ω-caproamide)",
"polycaprolactam",
"poly-[imino-(1-oxohexamethylene)]"
]
}
]
31 changes: 31 additions & 0 deletions whyis/materialsmine/ChemDatabase/notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Chemical Property Database Ingestion

## RDF Structure
Pure pseudocode:
```
chemical
id $ID;
stdname $STD_NAME;
abbreviations $ABBREV_1, $ABBREV_2, ..., $ABBREV_N;
density $DENSITY;
tradenames $TRADENAME_1, $TRADENAME_2, ..., $TRADENAME_N;
synonyms $SYNONYM_1, $SYNONYM_2, ..., $SYNONYM_N;
```

Applying our ontology:
```
PREFIX sio: <http://semanticscience.org/resource/>
PREFIX nanomine: <http://nanomine.org/ns/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

sio:ChemicalSubstance
nanomine:CU_Formula $ID;
rdfs:label $STD_NAME;
nanomine:Abbreviation $ABBREV_1, $ABBREV_2, ..., $ABBREV_N;
sio:Density $DENSITY
nanomine:TradeName $TRADENAME_1, $TRADENAME_2, ..., $TRADENAME_N;
sio:Synonym $SYNONYM_1, $SYNONYM_2, ..., $SYNONYM_N;

```

So using this pattern, we have to write an SETLr ingest script to import the data from the JSON files into the knowledge graph.
Loading