stages:
  - build
  - prepare
  - train

baseimg:
  stage: build
  tags:
    - emblem-dev2
  script:
    - make -C baseimg
  when: manual

fetch_and_preprocess:
  only:
    - main
  stage: prepare
  tags:
    - ailab
  timeout: 5h
  before_script:
    - if ! test -d $HOME/venv; then python3 -m venv $HOME/venv; source $HOME/venv/bin/activate; pip install --upgrade pip; fi
    - source $HOME/venv/bin/activate
    - |
      if ! cmp -s ./baseimg/requirements.txt $HOME/venv/requirements.txt; then
        pip install -r ./baseimg/requirements.txt && cp ./baseimg/requirements.txt $HOME/venv/;
      fi
    - mkdir -p $HOME/emblem5-data
  script:
    - export DATA_DIR=$HOME/emblem5-data
    - mkdir -p $DATA_DIR
    - time make fetch

train: &train_base
  only:
    - main
  stage: train
  tags:
    - ailab
  before_script:
    - source $HOME/venv/bin/activate
    - export DATA_DIR=$HOME/emblem5-data
  script:
    - echo "to be implemented"
  artifacts:
    paths:
      - models/*
    expire_in: 7 days