Skip to content

Commit

Permalink
fix distinction between hostside and dockerside paths
Browse files Browse the repository at this point in the history
  • Loading branch information
robinpdev committed May 22, 2024
1 parent 60d6149 commit 4f0faaa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
18 changes: 11 additions & 7 deletions backend/pigeonhole/apps/submissions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
from django.conf import settings


SUBMISSION_PATH = os.environ.get('SUBMISSION_PATH')
SUBMISSIONS_PATH = os.environ.get('SUBMISSIONS_PATH')
registry_name = os.environ.get('REGISTRY_NAME')

def submission_folder_path(group_id, submission_id):
return f"{str(settings.STATIC_ROOT)}/submissions/group_{group_id}/{submission_id}"

def submission_folder_path_hostside(group_id, submission_id):
return f"{SUBMISSIONS_PATH}/group_{group_id}/{submission_id}"

# TODO test timestamp, file, output_test
def submission_file_path(group_id, submission_id, relative_path):
Expand Down Expand Up @@ -81,12 +83,12 @@ def eval(self):
image=image_id,
name=f'pigeonhole-submission-{self.submission_id}-evaluation',
detach=False,
remove=True,
remove=False, # TODO: set to true after testing
environment={
'SUBMISSION_ID': self.submission_id,
},
volumes={
f'{submission_folder_path(group_id=self.group_id.group_id, submission_id=self.submission_id)}': {
f'{submission_folder_path_hostside(group_id=self.group_id.group_id, submission_id=self.submission_id)}': {
'bind': '/usr/src/submission/',
'mode': 'ro'
}
Expand All @@ -97,15 +99,17 @@ def eval(self):
# exit code 0 as a successful submission
# The container object returns the container logs and can be analyzed further

self.eval_output = container.logs()
print(self.eval_output)
#self.eval_output = container.logs()
#print(self.eval_output)

container.remove(force=True)
#container.remove(force=True)

except ContainerError as ce:
print(ce)
self.eval_result = False
print("container failed")
self.eval_result = False
client.close()
return

except APIError as e:
raise IOError(f'There was an error evaluation the submission: {e}')
Expand Down
1 change: 1 addition & 0 deletions backend/pigeonhole/apps/submissions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def create(self, request, *args, **kwargs):
for chunk in file.chunks():
dest.write(chunk)
# submission.file_urls = '[el path]'
print("Uploaded file: " + filepathstring)
except IOError as e:
print(e)
return Response(
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ services:
- ./backend/:/usr/src/app/backend/
#- submissions:/usr/src/app/backend/uploads/submissions/
- /var/run/docker.sock:/var/run/docker.sock
- ${SUBMISSIONS_PATH}:/home/app/web/submissions
- ${SUBMISSIONS_PATH}:/usr/src/app/backend/static/submissions/
ports:
- 8000:8000
env_file:
Expand Down

0 comments on commit 4f0faaa

Please sign in to comment.