Soutrik commited on
Commit
1bcc0f7
·
1 Parent(s): 9e7b284

basic cleanup ci

Browse files
Files changed (1) hide show
  1. .github/workflows/ci.yaml +32 -70
.github/workflows/ci.yaml CHANGED
@@ -19,12 +19,11 @@ jobs:
19
  python-version: [3.10.15]
20
 
21
  env:
22
- AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
23
- AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
24
- AWS_REGION: ${{ secrets.AWS_REGION }}
25
 
26
  steps:
27
- # Step 0: Configure AWS credentials
28
  - name: Configure AWS credentials
29
  uses: aws-actions/configure-aws-credentials@v4
30
  with:
@@ -32,157 +31,120 @@ jobs:
32
  aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
33
  aws-region: ${{ secrets.AWS_REGION }}
34
 
35
- # Step 1: Print the branch name
36
  - name: Print branch name
37
  run: echo "Branch name is ${{ github.ref_name }}"
38
 
39
- # Step 2: Checkout the repository code
40
  - name: Checkout code
41
  uses: actions/checkout@v3
42
 
43
- # Step 3: Set up Python environment with the specified version
44
  - name: Set up Python ${{ matrix.python-version }}
45
  uses: actions/setup-python@v4
46
  with:
47
  python-version: ${{ matrix.python-version }}
48
 
49
- # Step 4: Install Poetry and set virtualenv to be created inside the project directory
50
  - name: Install Poetry
51
  run: |
52
  python -m pip install --upgrade pip
53
  pip install poetry
54
- poetry config virtualenvs.in-project true # Ensure the virtual environment is created in the project directory
55
 
56
- # Step 5: Cache Poetry dependencies
57
  - name: Cache Poetry dependencies
58
  uses: actions/cache@v3
59
  with:
60
  path: |
61
- .venv # Cache the virtual environment in the project directory
62
  ~/.cache/pypoetry
63
  key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
64
  restore-keys: |
65
  ${{ runner.os }}-poetry-
66
 
67
- # Step 6: Install dependencies with Poetry
68
  - name: Install dependencies
69
- run: |
70
- poetry install --no-root
71
 
72
- # Step 7: Check Poetry environment
73
  - name: Check Poetry environment
74
- run: |
75
- source .venv/bin/activate
76
- poetry env info
77
 
78
- # Step 8: Set environment variables from GitHub Secrets and write to .env
79
  - name: Create .env file
80
  run: |
81
- echo "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" >> .env
82
- echo "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" >> .env
83
- echo "AWS_REGION=${AWS_REGION}" >> .env
84
- echo ".env file created"
85
 
86
- # Step 9: Run lint checks at the root level
87
  - name: Run lint checks
88
- run: |
89
- source .venv/bin/activate
90
- flake8 . --exclude=.venv,tests,notebooks
91
-
92
- # Step 10: Run black code formatter at the root level
93
  - name: black
94
- run: |
95
- source .venv/bin/activate
96
- black . --exclude=.venv,tests,notebooks
97
-
98
-
99
  pytorch_code_test:
100
  name: Test PyTorch code
101
  runs-on: self-hosted
102
 
103
  env:
104
- AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
105
- AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
106
- AWS_REGION: ${{ secrets.AWS_REGION }}
107
-
108
 
109
- needs: python_basic_test # This ensures pytorch_code_test runs only after python_basic_test completes successfully
110
 
111
  strategy:
112
  matrix:
113
  python-version: [3.10.15]
114
 
115
  steps:
116
- # Step 0: Configure AWS credentials
117
  - name: Configure AWS credentials
118
  uses: aws-actions/configure-aws-credentials@v4
119
  with:
120
- aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
121
- aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
122
- aws-region: ${{ secrets.AWS_REGION }}
123
-
124
- # Step 1: Checkout the repository code
125
  - name: Checkout code
126
  uses: actions/checkout@v3
127
 
128
- # Step 2: Set up Python environment with the specified version
129
  - name: Set up Python ${{ matrix.python-version }}
130
  uses: actions/setup-python@v4
131
  with:
132
  python-version: ${{ matrix.python-version }}
133
 
134
- # Step 3: Install Poetry and set virtualenv to be created inside the project directory
135
  - name: Install Poetry
136
  run: |
137
  python -m pip install --upgrade pip
138
  pip install poetry
139
- poetry config virtualenvs.in-project true # Ensure the virtual environment is created in the project directory
140
 
141
- # Step 4: Cache Poetry dependencies
142
  - name: Cache Poetry dependencies
143
  uses: actions/cache@v3
144
  with:
145
  path: |
146
- .venv # Cache the virtual environment in the project directory
147
  ~/.cache/pypoetry
148
  key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
149
  restore-keys: |
150
  ${{ runner.os }}-poetry-
151
 
152
- # Step 5: Install dependencies with Poetry
153
  - name: Install dependencies
154
- run: |
155
- poetry install --no-root
156
 
157
- # Step 6: Check Poetry environment
158
  - name: Check Poetry environment
159
- run: |
160
- source .venv/bin/activate
161
- poetry env info
162
 
163
- # Step 7: DVD Pull to get data
164
  - name: Get data from DVC
165
  run: |
166
- source .venv/bin/activate
167
- echo "Getting data from DVC"
168
- dvc pull || echo "No data to pull from DVC"
169
 
170
- # Step 8: Run Train code
171
  - name: Run Train code
172
  run: |
173
- source .venv/bin/activate
174
  echo "Training the model"
175
- python -m src.train_optuna_callbacks experiment=catdog_experiment ++task_name=train ++train=True ++test=False
176
- python -m src.create_artifacts
177
 
178
- # Step 9: Run the model testing code
179
  - name: Run Test code
180
  run: |
181
- source .venv/bin/activate
182
  echo "Testing the model"
183
- python -m src.train_optuna_callbacks experiment=catdog_experiment ++task_name=test ++train=False ++test=True
184
-
185
- # Step 10: Upload the model checkpoints, logs, and configs as artifacts
186
  - name: upload model checkpoints
187
  uses: actions/upload-artifact@v4
188
  with:
 
19
  python-version: [3.10.15]
20
 
21
  env:
22
+ AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
23
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
24
+ AWS_REGION: ${{ secrets.AWS_REGION }}
25
 
26
  steps:
 
27
  - name: Configure AWS credentials
28
  uses: aws-actions/configure-aws-credentials@v4
29
  with:
 
31
  aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
32
  aws-region: ${{ secrets.AWS_REGION }}
33
 
 
34
  - name: Print branch name
35
  run: echo "Branch name is ${{ github.ref_name }}"
36
 
 
37
  - name: Checkout code
38
  uses: actions/checkout@v3
39
 
 
40
  - name: Set up Python ${{ matrix.python-version }}
41
  uses: actions/setup-python@v4
42
  with:
43
  python-version: ${{ matrix.python-version }}
44
 
 
45
  - name: Install Poetry
46
  run: |
47
  python -m pip install --upgrade pip
48
  pip install poetry
49
+ poetry config virtualenvs.in-project true
50
 
 
51
  - name: Cache Poetry dependencies
52
  uses: actions/cache@v3
53
  with:
54
  path: |
55
+ .venv
56
  ~/.cache/pypoetry
57
  key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
58
  restore-keys: |
59
  ${{ runner.os }}-poetry-
60
 
 
61
  - name: Install dependencies
62
+ run: poetry install --no-root --no-interaction
 
63
 
 
64
  - name: Check Poetry environment
65
+ run: poetry env info
 
 
66
 
 
67
  - name: Create .env file
68
  run: |
69
+ echo "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" >> .env
70
+ echo "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" >> .env
71
+ echo "AWS_REGION=${AWS_REGION}" >> .env
72
+ echo ".env file created"
73
 
 
74
  - name: Run lint checks
75
+ run: poetry run flake8 . --exclude=.venv,tests,notebooks
76
+
 
 
 
77
  - name: black
78
+ run: poetry run black . --exclude=.venv,tests,notebooks
79
+
 
 
 
80
  pytorch_code_test:
81
  name: Test PyTorch code
82
  runs-on: self-hosted
83
 
84
  env:
85
+ AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
86
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
87
+ AWS_REGION: ${{ secrets.AWS_REGION }}
 
88
 
89
+ needs: python_basic_test
90
 
91
  strategy:
92
  matrix:
93
  python-version: [3.10.15]
94
 
95
  steps:
 
96
  - name: Configure AWS credentials
97
  uses: aws-actions/configure-aws-credentials@v4
98
  with:
99
+ aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
100
+ aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
101
+ aws-region: ${{ secrets.AWS_REGION }}
102
+
 
103
  - name: Checkout code
104
  uses: actions/checkout@v3
105
 
 
106
  - name: Set up Python ${{ matrix.python-version }}
107
  uses: actions/setup-python@v4
108
  with:
109
  python-version: ${{ matrix.python-version }}
110
 
 
111
  - name: Install Poetry
112
  run: |
113
  python -m pip install --upgrade pip
114
  pip install poetry
115
+ poetry config virtualenvs.in-project true
116
 
 
117
  - name: Cache Poetry dependencies
118
  uses: actions/cache@v3
119
  with:
120
  path: |
121
+ .venv
122
  ~/.cache/pypoetry
123
  key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
124
  restore-keys: |
125
  ${{ runner.os }}-poetry-
126
 
 
127
  - name: Install dependencies
128
+ run: poetry install --no-root --no-interaction
 
129
 
 
130
  - name: Check Poetry environment
131
+ run: poetry env info
 
 
132
 
 
133
  - name: Get data from DVC
134
  run: |
135
+ poetry run dvc pull || echo "No data to pull from DVC"
 
 
136
 
 
137
  - name: Run Train code
138
  run: |
 
139
  echo "Training the model"
140
+ poetry run python -m src.train_optuna_callbacks experiment=catdog_experiment ++task_name=train ++train=True ++test=False || exit 1
141
+ poetry run python -m src.create_artifacts
142
 
 
143
  - name: Run Test code
144
  run: |
 
145
  echo "Testing the model"
146
+ poetry run python -m src.train_optuna_callbacks experiment=catdog_experiment ++task_name=test ++train=False ++test=True || exit 1
147
+
 
148
  - name: upload model checkpoints
149
  uses: actions/upload-artifact@v4
150
  with: