Skip to content

Commit 0ddb575

Browse files
committed
First Commit triggered on push
0 parents  commit 0ddb575

6 files changed

Lines changed: 105836 additions & 0 deletions

File tree

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: 📦 Auto Modularize Notebook on Push
2+
on:
3+
push:
4+
branches: [main]
5+
jobs:
6+
convert-notebook-to-package:
7+
name: 🧠 Classify & Modularize Notebook
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: 📥 Checkout repository
12+
uses: actions/checkout@v3
13+
14+
- name: 🐍 Set up Python
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: 3.9
18+
19+
- name: 📁 Detect newly pushed notebook
20+
id: detect_notebook
21+
run: |
22+
pip install -r requirements.txt
23+
NOTEBOOK=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '^notebooks/.*\.ipynb$' | head -n1 || true)
24+
25+
if [ -z "$NOTEBOOK" ]; then
26+
echo "❌ No new notebook found in notebooks/ directory. Skipping workflow."
27+
exit 1
28+
fi
29+
30+
echo "NOTEBOOK=$NOTEBOOK" >> $GITHUB_ENV
31+
echo "BASENAME=$(basename "$NOTEBOOK" .ipynb)" >> $GITHUB_ENV
32+
echo "REPO_NAME=$(basename $(git rev-parse --show-toplevel))" >> $GITHUB_ENV
33+
34+
35+
- name: 🧰 Install dependencies and clone jupylab_cli
36+
run: |
37+
git clone https://github.com/m1guelperez/jupylab_cli.git
38+
cd jupylab_cli
39+
pip install .
40+
pip install -r requirements.txt
41+
42+
- name: 🧪 Prepare notebook for classification
43+
run: |
44+
cd jupylab_cli
45+
mkdir -p src/pipeline_analyzer/jn_analyzer/resources/{inputs,outputs,backups}
46+
cp $NOTEBOOK src/pipeline_analyzer/jn_analyzer/resources/inputs/
47+
jupyter nbconvert --ClearOutputPreprocessor.enabled=True --inplace src/pipeline_analyzer/jn_analyzer/resources/inputs/$(basename $NOTEBOOK)
48+
49+
- name: 🏷️ Classify notebook cells
50+
run: |
51+
cd jupylab_cli
52+
analyze label-notebooks --debug False --headers False
53+
cd ..
54+
55+
- name: 🏗️ Modularize into production-ready Python package
56+
run: |
57+
python modularize_tagged_nb.py jupylab_cli/src/pipeline_analyzer/jn_analyzer/resources/outputs/$(basename $NOTEBOOK)
58+
59+
- name: 📂 Copy data into the new ml_project folder
60+
run: |
61+
cp -r data/* ml_project/data/
62+
63+
- name: ✅ Run the output project (basic validation)
64+
run: |
65+
cd ml_project
66+
pip install -r requirements.txt
67+
python main.py || echo "Main script failed, but pipeline completed."
68+
69+
- name: 🚀 Push back the generated project to the repo
70+
run: |
71+
git config user.name "Kh0uloud"
72+
git config user.email "ismailkhouloud9@gmail.com"
73+
git add ml_project
74+
git commit -m "🤖 Auto-generated ml_project from $NOTEBOOK"
75+
git push origin main

0 commit comments

Comments
 (0)