Skip to content

Commit

Permalink
git commithash to files only if repo
Browse files Browse the repository at this point in the history
  • Loading branch information
cstenkamp committed Oct 28, 2021
1 parent ee85252 commit 2478c23
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ 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

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
Expand All @@ -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
ENV SHELL=/bin/zsh
8 changes: 0 additions & 8 deletions docker/entrypoint.sh

This file was deleted.

2 changes: 1 addition & 1 deletion src/fb_classifier/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 1 addition & 5 deletions src/fb_classifier/util/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
return lines
9 changes: 8 additions & 1 deletion src/main/load_data/siddata_data_prep/jsonloadstore.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""https://stackoverflow.com/a/47626762/5122790"""
import json
import os
import subprocess
from datetime import datetime

Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 2478c23

Please sign in to comment.