diff --git a/Dockerfile b/Dockerfile index 3899609..d52662c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,7 @@ FROM python:${PYTHON_VERSION}-buster ARG uid ARG gid +ARG git_commit RUN apt-get update \ && apt-get install -y bash git vim curl zsh htop tmux unzip nano @@ -15,10 +16,12 @@ RUN apt-get update \ ARG WORKDIR=/opt/derive_conceptualspaces COPY . ${WORKDIR} WORKDIR ${WORKDIR} + ENV PYTHONPATH=${WORKDIR} ENV RUNNING_IN_DOCKER=1 ENV CREATE_UID=${uid} ENV CREATE_GID=${gid} +ENV CONTAINER_GIT_COMMIT=${git_commit} RUN ln -sf /usr/local/bin/python3 /usr/bin/python3 RUN ln -sf /usr/bin/python3 /usr/bin/python @@ -42,6 +45,4 @@ USER developer RUN /bin/zsh /home/developer/.zshrc ENV HOME=/home/developer -ENV SHELL=/bin/zsh - -#ENTRYPOINT ${WORKDIR}/docker/entrypoint.sh \ No newline at end of file +ENV SHELL=/bin/zsh \ No newline at end of file diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh deleted file mode 100644 index 34b6f62..0000000 --- a/docker/entrypoint.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -groupadd --force --gid ${APP_GID} appuser -useradd -c 'container user' -u $APP_UID -g $APP_GID appuser -chown -R $APP_UID:$APP_GID /app/data -exec $@ - -#TODO deleteme! \ No newline at end of file diff --git a/src/fb_classifier/train.py b/src/fb_classifier/train.py index 2cf9564..71c86ad 100644 --- a/src/fb_classifier/train.py +++ b/src/fb_classifier/train.py @@ -9,7 +9,7 @@ from src.fb_classifier.model import FB_Classifier from src.fb_classifier.util.debug_tools import debug_tf_function from src.fb_classifier.dataset import get_dset_len -from src.fb_classifier.util.misc import check_config, get_git_revision_short_hash, get_ann_configs +from src.fb_classifier.util.misc import check_config, get_ann_configs flatten_dict = lambda data: dict((key,d[key]) for d in data for key in d) diff --git a/src/fb_classifier/util/misc.py b/src/fb_classifier/util/misc.py index 6f313ff..fc6ab87 100644 --- a/src/fb_classifier/util/misc.py +++ b/src/fb_classifier/util/misc.py @@ -69,8 +69,4 @@ def get_ann_configs(): lines.append(line.strip()) elif 'ANN Settings' in line: ann_sets = True - return lines - - -def get_git_revision_short_hash(): - return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('utf-8').strip() \ No newline at end of file + return lines \ No newline at end of file diff --git a/src/main/load_data/siddata_data_prep/jsonloadstore.py b/src/main/load_data/siddata_data_prep/jsonloadstore.py index 717e413..6fd603a 100644 --- a/src/main/load_data/siddata_data_prep/jsonloadstore.py +++ b/src/main/load_data/siddata_data_prep/jsonloadstore.py @@ -1,5 +1,6 @@ """https://stackoverflow.com/a/47626762/5122790""" import json +import os import subprocess from datetime import datetime @@ -58,7 +59,13 @@ def npify_rek(di): return res def get_commithash(): - return subprocess.check_output(["git", "rev-parse", "HEAD"]).strip().decode("UTF-8") + try: + return subprocess.check_output(["git", "rev-parse", "HEAD"]).strip().decode("UTF-8").strip() + except subprocess.CalledProcessError: + if os.getenv("RUNNING_IN_DOCKER"): + import socket + return f"cont_commit: {os.getenv('CONTAINER_GIT_COMMIT', 'None')}, cont_hostname: {socket.gethostname()}" + return "no_commit" #TODO: return something reasonable when no repo! def get_settings():