Skip to content

Commit

Permalink
Script for branch deploy (#367)
Browse files Browse the repository at this point in the history
* script

* Automated changes

* Automated changes

* change also keys

* write

* Automated changes

* Automated changes

* force chapters

* tweak project

* Tweak project delete entry

* Automated changes

* Automated changes

* cat file

* Automated changes

* Automated changes

* tweak chapters in case

* Automated changes

* Automated changes

* essaye comme ça

* forcing value

* Automated changes

* Automated changes

* try

* Automated changes

* Automated changes

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: root <root@vscode-python-27639-0.vscode-python-27639.projet-funathon.svc.cluster.local>
  • Loading branch information
3 people committed Jul 3, 2023
1 parent ed81531 commit 64baaf8
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 89 deletions.
83 changes: 2 additions & 81 deletions .github/workflows/netlify-test.yaml
Expand Up @@ -28,7 +28,9 @@ jobs:
- name: Render website
run: |
git diff --name-only origin/master origin/${GITHUB_HEAD_REF} >> diff
python build/tweak_chapters.py
python build/tweak_render.py
cat _quarto.yml
quarto render --to html
python build/wc_website.py
python build/tweak_markdown.py
Expand Down Expand Up @@ -98,14 +100,11 @@ jobs:
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
# git config user.email github-actions@github.com
#git checkout ${BRANCHE_REF}
git status
find notebooks -type f -name "*.ipynb" | xargs git add
git commit -m "Automated changes";
git pull
git push
git push
corrections:
name: Render-Blog
runs-on: ubuntu-latest
Expand Down Expand Up @@ -144,8 +143,6 @@ jobs:
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
# git config user.email github-actions@github.com
#git checkout ${BRANCHE_REF}
git status
find corrections -type f -name "*.ipynb" | xargs git add
git commit -m "Automated changes";
Expand All @@ -155,79 +152,3 @@ jobs:
# corrections:
# runs-on: ubuntu-latest
# container: linogaliana/python-datascientist:latest
# steps:
# - uses: actions/checkout@v2
# with:
# submodules: true
# fetch-depth: 0
# ref: ${{ github.event.pull_request.head.ref }}
# repository: ${{github.event.pull_request.head.repo.full_name}}
# - name: Install rmarkdown
# env:
# GITHUB_PAT: ${{ secrets.PAT_GITHUB }}
# run: |
# Rscript -e 'remotes::install_github("yihui/xfun")'
# Rscript -e 'remotes::install_github("yihui/knitr")'
# Rscript -e 'install.packages(c("rmarkdown"))'
# - name: Install Python
# run: |
# Rscript -e "install.packages(c('remotes', 'reticulate'))"
# Rscript -e "install.packages(c('here'))"
# - shell: bash -l {0}
# run: |
# conda info
# conda list
# - name: Modif Rmd echo status
# run: |
# python build/modifmd.py
# - name: Build to md
# run: |
# git diff --name-only origin/master origin/${GITHUB_HEAD_REF} >> diff.txt
# cat diff.txt
# Rscript -e 'source("./build/build_light.R")'
# - name: Clean files with Python function
# run: |
# rm -rf "./temp"
# mkdir -p temp
# mkdir -p corrections
# python build/cleanmd.py
# - name: Convert in ipynb with Jupytext
# run: |
# pip install jupytext
# cd ./temp
# for i in $(find . -type f \( -iname "*.Rmd" \)); do \
# j="${i%.Rmd}.md" ;
# echo "$j" ;
# if [ -e $j ]
# then
# echo "Converting $j"; \
# #jupytext --to py --execute "$i"
# jupytext --to ipynb "$j" ;
# k="${j%.md}.ipynb" ;
# fi
# done
# mkdir -p ../corrections
# cp -R . ../corrections
# cd ..
# - uses: actions/upload-artifact@v2
# with:
# name: Corrections
# path: corrections/
# - name: Commit new notebooks
# if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
# env:
# BRANCHE_REF: ${{ github.event.pull_request.head.ref }}
# run: |
# git config user.name 'github-actions[bot]'
# git config user.email 'github-actions[bot]@users.noreply.github.com'
# # git config user.email github-actions@github.com
# #git checkout ${BRANCHE_REF}
# git status
# git add corrections/**/*.ipynb;
# git commit -m "Automated changes";
# git pull
# git push

21 changes: 21 additions & 0 deletions build/tweak_chapters.py
@@ -0,0 +1,21 @@
import yaml

# Specify the file to be modified
file_path = "_quarto.yml"

# Load the YAML file
with open(file_path, 'r') as file:
data = yaml.safe_load(file)

# Define the replacement mappings
replacements = {
"book": "website",
"Book": "Website",
"BOOK": "WEBSITE"
}

del data['book']['chapters']

# Write the modified data back to the YAML file
with open(file_path, 'w') as file:
yaml.dump(data, file)
10 changes: 7 additions & 3 deletions build/tweak_project.py
Expand Up @@ -14,24 +14,28 @@
"BOOK": "WEBSITE"
}

del data['book']['chapters']

# Function to recursively replace values in a dictionary
def replace_values(data):
if isinstance(data, dict):
for key, value in data.items():
for key, value in list(data.items()):
if isinstance(value, str):
for old, new in replacements.items():
value = value.replace(old, new)
data[key] = value
elif isinstance(value, (dict, list)):
else:
replace_values(value)
if key in replacements:
data[replacements[key]] = data.pop(key)
elif isinstance(data, list):
for i in range(len(data)):
replace_values(data[i])


# Replace the values in the loaded data
replace_values(data)


# Write the modified data back to the YAML file
with open(file_path, 'w') as file:
yaml.dump(data, file)
16 changes: 11 additions & 5 deletions build/tweak_render.py
Expand Up @@ -2,7 +2,9 @@
import glob
import yaml

with open("_quarto.yml", "r") as stream:
file_path = "_quarto.yml"

with open(file_path, "r") as stream:
config = yaml.load(stream, Loader=yaml.FullLoader)

if os.path.exists('diff'):
Expand All @@ -16,13 +18,17 @@
for dir in ["manipulation", "visualisation", "modelisation", "NLP", "modern-ds"]
]
lines += [f"content/course/index.qmd"]
lines += [f"!content/slides/intro/index.qmd"]
lines += [f"index.qmd"]

print(lines)
config['project']['render'] = lines
config.setdefault('book', {})['chapters'] = lines

lines2 = lines + ["!content/slides/intro/index.qmd"]


print(lines2)
config['project']['render'] = lines2

with open('_quarto_temp.yml', 'w') as outfile:
with open(file_path, 'w') as outfile:
yaml.dump(config, outfile, default_flow_style=False)

print("Done")
1 change: 1 addition & 0 deletions content/course/manipulation/02a_pandas_tutorial/index.qmd
Expand Up @@ -1154,6 +1154,7 @@ L'utilisation des `pipe` rend le code très lisible et peut être très
pratique lorsqu'on enchaine des opérations sur le même
_dataset_.


# Quelques enjeux de performance

La librairie `Dask` intègre la structure de `numpy`, `pandas` et `sklearn`.
Expand Down

0 comments on commit 64baaf8

Please sign in to comment.