name: model-training
on: 
  push:
    branches:
      - mlmodel
permissions: write-all
jobs:
  run:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      # TODO: use dvc to pull data, mkdir s3-mock, load data, then use docker compose
      # - name: Build docker compose stack
      #   run: |
      #     cd model_data/simulation_system 
      #     docker-compose up -d 
      - uses: actions/setup-python@v4
      - uses: iterative/setup-cml@v1
      - name: Train model
        env:
          REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          ls
          cd model_data/simulation_system 
          pip install -r requirements/training/training.txt
          python3 training.py --train-filepath ./model_build_data/change_data/rdsap_full/train_validation_data.parquet --test-filepath ./model_build_data/change_data/rdsap_full/test_data.parquet

          cd model_directory/RDSAP_CHANGE
          echo "## Model metrics" > report.md
          metrics_location=$(find . -maxdepth 10 -name "metrics.md")
          echo $metrics_location 
          cat $metrics_location >> report.md
          
          # echo "## Residuals plot from model" >> report.md
          # metrics_location=$(find . -maxdepth 10 -name "residuals.png")
          # echo $metrics_location
          # cd $metric_location
          # echo "![](./residuals.png)" >> report.md

          cml comment create report.md

          # cml comment create --log debug --publish false report.md
          
