Skip to content

Commit

Permalink
Updated paths to conform with scilife serve team suggestions.
Browse files Browse the repository at this point in the history
Also fixed bug in chembl version selection.
  • Loading branch information
morganekmefjord committed Dec 13, 2024
1 parent 887bd74 commit b01c2a6
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 16 deletions.
1 change: 1 addition & 0 deletions docker-compose-single.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ services:
#- EMAIL_HOST_USER=your-email@example.com
#- EMAIL_HOST_PASSWORD=your-email-password
- SITE_URL=http://localhost:8000
- CSRF_TRUSTED_ORIGINS=http://localhost:8000

#volumes:
# postgres_data:
28 changes: 17 additions & 11 deletions ptp/inference/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

@shared_task
def run_inference(job_id):

import os
job = InferenceJob.objects.get(id=job_id)
job.status = 'running'
job.save()
Expand All @@ -32,11 +32,12 @@ def run_inference(job_id):
else:
path = 'conformal_models'

print("JOB CHEMBL VERSION:{}:VERSION".format(job.chembl_version), flush=True)
if str(job.chembl_version) == '31':
chembl_version = 'chembl_31'
if str(job.chembl_version) == '32':
elif str(job.chembl_version) == '32':
chembl_version = 'chembl_32'
if str(job.chembl_version) == '33':
elif str(job.chembl_version) == '33':
chembl_version = 'chembl_33'
elif str(job.chembl_version) == '34':
chembl_version = 'chembl_34'
Expand All @@ -54,11 +55,8 @@ def run_inference(job_id):
results = []
result_filenames = []
print("Running inference...", flush=True)
DEBUG=True
import os

if DEBUG:
print("RUNNING IN DEBUG MODE ONLY CALCULATING 3 MODELS", flush=True)
model_files = model_files#[:5]
if max_models:
model_files = model_files[:int(max_models)]

Expand Down Expand Up @@ -115,6 +113,7 @@ def run_inference(job_id):
print("Concatenating results...", flush=True)

BASE_DIR = os.environ.get("BASE_DIR", "/app/")
import os
os.makedirs(f"{BASE_DIR}/interim", exist_ok=True)
result_file_path = f"{BASE_DIR}/interim/resultfilepath-{job_id}.csv"

Expand Down Expand Up @@ -157,7 +156,7 @@ def run_inference(job_id):
df_result[target + '_p_i'] = df_result['SMILES'].map(p_i)
df_result[target + '_p_a'] = df_result['SMILES'].map(p_a)

df_result.drop(axis='index', labels=0, inplace=True)
##### df_result.drop(axis='index', labels=0, inplace=True)
#print("Finished processing file:", p, flush=True)
df_result.to_csv(result_file_path, index=False)
#print("saving to resultfile path", flush=True)
Expand All @@ -184,11 +183,18 @@ def run_inference(job_id):
# Save result in Django model
#job.result_file.name = f"results/{job_id}_final_result.csv"
import uuid
identifier = str(uuid.uuid4())
identifier = str(uuid.uuid4()).split('-')[0]
if result_file_path:
with open(result_file_path, 'rb') as f:
result = Result.objects.create(job=job)
result.result_file.save(f"{job_id}_{identifier}_result.csv", f)
try:
result = Result.objects.create(job=job)
result.result_file.save(f"{job_id}_{identifier}_result.csv", f)
result.save()
except Exception as e:
job.status = 'failed'
job.save()
cleanup_output_files(output_dir)
print("Failed to save result from interim:", e, flush=True)

#job.result_file.name = f"results/{job_id}_final_result.csv"

Expand Down
2 changes: 1 addition & 1 deletion ptp/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ http {
alias /app/static/;
}
location /media/ {
alias /app/media/;
alias /app/ext_storage/media/;
types {
text/csv csv;
}
Expand Down
2 changes: 1 addition & 1 deletion ptp/ptp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
# Media files (Uploaded files, results)
MEDIA_URL = '/media/'

MEDIA_DIR = os.environ.get('MEDIA_DIR', '/app/ext_storage/media')
MEDIA_DIR = os.environ.get('MEDIA_DIR', '/app/ext_storage/')
MEDIA_ROOT = os.path.join(MEDIA_DIR, 'media')

# Email settings (for sending job completion notifications)
Expand Down
6 changes: 4 additions & 2 deletions ptp/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ autostart=true
autorestart=true
startretries=10
exitcodes=0,2
stdout_logfile=/var/log/supervisor/celery.log
stderr_logfile=/var/log/supervisor/celery_error.log
#stdout_logfile=/var/log/supervisor/celery.log
#stderr_logfile=/var/log/supervisor/celery_error.log
stdout_logfile=/dev/stdout
stderr_logfile=/dev/stderr
startsecs=5
3 changes: 2 additions & 1 deletion test/smiles_example.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SMILES, Name
CC(=O)NCCC1=CNc2c1cc(OC)cc2,Melatonin
O=Cc1ccc(O)c(OC)c1,Vanillin
O=Cc1ccc(O)c(OC)c1,Vanillin

0 comments on commit b01c2a6

Please sign in to comment.