Spaces:
Running
Running
change pipeline
Browse files- .github/workflows/pipeline.yaml +69 -6
- Dockerfile +13 -0
- pipeline_schedule.ctl +1 -0
.github/workflows/pipeline.yaml
CHANGED
|
@@ -24,34 +24,97 @@ jobs:
|
|
| 24 |
persist-credentials: false
|
| 25 |
fetch-depth: 1
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
- name: Scraping Yahoo Finance
|
|
|
|
| 28 |
run: go run scraper.go
|
| 29 |
|
| 30 |
- name: Install Libraries
|
|
|
|
| 31 |
run: pip install -r requirements.txt
|
| 32 |
|
| 33 |
- name: Modeling and Training
|
|
|
|
| 34 |
run: python training.py
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
- name: Commit changes
|
|
|
|
| 37 |
run: |
|
| 38 |
git config --local user.email "[email protected]"
|
| 39 |
git config --local user.name "belajarqywok"
|
| 40 |
git add -A
|
| 41 |
-
git commit -m "
|
| 42 |
|
| 43 |
- name: Push changes
|
|
|
|
| 44 |
uses: ad-m/github-push-action@master
|
| 45 |
with:
|
| 46 |
github_token: ${{ secrets.GH_TOKEN }}
|
| 47 |
-
branch: main
|
| 48 |
|
| 49 |
-
|
| 50 |
-
name: Deployment
|
| 51 |
runs-on: ubuntu-latest
|
| 52 |
needs: extraction_train_modeling
|
| 53 |
environment: Production
|
| 54 |
|
| 55 |
steps:
|
| 56 |
-
- name:
|
| 57 |
-
run:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
persist-credentials: false
|
| 25 |
fetch-depth: 1
|
| 26 |
|
| 27 |
+
- name: Read pipeline schedule date
|
| 28 |
+
id: read_schedule
|
| 29 |
+
run: |
|
| 30 |
+
SCHEDULE_DATE=$(cat pipeline_schedule.ctl)
|
| 31 |
+
echo "schedule_date=${SCHEDULE_DATE}" >> $GITHUB_ENV
|
| 32 |
+
|
| 33 |
+
- name: Get current date
|
| 34 |
+
id: get_date
|
| 35 |
+
run: echo "current_date=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
|
| 36 |
+
|
| 37 |
+
- name: Check if dates match
|
| 38 |
+
id: date_check
|
| 39 |
+
run: |
|
| 40 |
+
if [ "$schedule_date" = "$current_date" ]; then
|
| 41 |
+
echo "match=true" >> $GITHUB_ENV
|
| 42 |
+
else
|
| 43 |
+
echo "match=false" >> $GITHUB_ENV
|
| 44 |
+
fi
|
| 45 |
+
|
| 46 |
- name: Scraping Yahoo Finance
|
| 47 |
+
if: env.match != 'true'
|
| 48 |
run: go run scraper.go
|
| 49 |
|
| 50 |
- name: Install Libraries
|
| 51 |
+
if: env.match != 'true'
|
| 52 |
run: pip install -r requirements.txt
|
| 53 |
|
| 54 |
- name: Modeling and Training
|
| 55 |
+
if: env.match != 'true'
|
| 56 |
run: python training.py
|
| 57 |
|
| 58 |
+
- name: Set Pipeline Schedule
|
| 59 |
+
if: env.match != 'true'
|
| 60 |
+
run: echo "$(date +'%Y-%m-%d')" > pipeline_schedule.ctl
|
| 61 |
+
|
| 62 |
- name: Commit changes
|
| 63 |
+
if: env.match != 'true'
|
| 64 |
run: |
|
| 65 |
git config --local user.email "[email protected]"
|
| 66 |
git config --local user.name "belajarqywok"
|
| 67 |
git add -A
|
| 68 |
+
git commit -m "Data Extraction, Training, and Modeling"
|
| 69 |
|
| 70 |
- name: Push changes
|
| 71 |
+
if: env.match != 'true'
|
| 72 |
uses: ad-m/github-push-action@master
|
| 73 |
with:
|
| 74 |
github_token: ${{ secrets.GH_TOKEN }}
|
| 75 |
+
branch: main
|
| 76 |
|
| 77 |
+
model_deployment:
|
| 78 |
+
name: Model Deployment
|
| 79 |
runs-on: ubuntu-latest
|
| 80 |
needs: extraction_train_modeling
|
| 81 |
environment: Production
|
| 82 |
|
| 83 |
steps:
|
| 84 |
+
- name: Set global directory
|
| 85 |
+
run: git config --global --add safe.directory /github/workspace
|
| 86 |
+
|
| 87 |
+
- uses: actions/checkout@v3
|
| 88 |
+
with:
|
| 89 |
+
persist-credentials: false
|
| 90 |
+
fetch-depth: 1
|
| 91 |
+
|
| 92 |
+
- name: Read pipeline schedule date
|
| 93 |
+
id: read_schedule
|
| 94 |
+
run: |
|
| 95 |
+
SCHEDULE_DATE=$(cat pipeline_schedule.ctl)
|
| 96 |
+
echo "schedule_date=${SCHEDULE_DATE}" >> $GITHUB_ENV
|
| 97 |
+
|
| 98 |
+
- name: Get current date
|
| 99 |
+
id: get_date
|
| 100 |
+
run: echo "current_date=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
|
| 101 |
+
|
| 102 |
+
- name: Check if dates match
|
| 103 |
+
id: date_check
|
| 104 |
+
run: |
|
| 105 |
+
if [ "$schedule_date" = "$current_date" ]; then
|
| 106 |
+
echo "match=true" >> $GITHUB_ENV
|
| 107 |
+
else
|
| 108 |
+
echo "match=false" >> $GITHUB_ENV
|
| 109 |
+
fi
|
| 110 |
+
|
| 111 |
+
- name: Push to Hugging Face
|
| 112 |
+
if: env.match != 'true'
|
| 113 |
+
env:
|
| 114 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 115 |
+
SPACE_NAME: cryptocurrency_prediction
|
| 116 |
+
HF_USERNAME: qywok
|
| 117 |
+
run: |
|
| 118 |
+
git add -A
|
| 119 |
+
git commit -m "Model Deployment"
|
| 120 |
+
git push https://$HF_USERNAME:[email protected]/spaces/$HF_USERNAME/$SPACE_NAME main
|
Dockerfile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.9
|
| 2 |
+
|
| 3 |
+
RUN useradd -m -u 1000 user
|
| 4 |
+
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
| 8 |
+
|
| 9 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 10 |
+
|
| 11 |
+
COPY --chown=user . /app
|
| 12 |
+
|
| 13 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
pipeline_schedule.ctl
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
2024-06-08
|