Skip to content

Commit

Permalink
Simplification de la structure 🤓 (#393)
Browse files Browse the repository at this point in the history
* Change structure

* restructure

* Simplify again structure

* Rename files

* change sys structure

* badges

* tweak render

* rm files

* rm functions not used

* Changing structure
  • Loading branch information
linogaliana committed Aug 25, 2023
1 parent 30823c4 commit 3bdf3b0
Show file tree
Hide file tree
Showing 66 changed files with 198 additions and 380 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/notebooks.yml
Expand Up @@ -24,7 +24,7 @@ jobs:
conda list
- name: Convert in ipynb with Quarto
run: |
find content/course -type f -name "*.qmd" >> diff
find content -type f -name "*.qmd" >> diff
cat diff
python build/tweak_project.py
python build/tweak_render.py
Expand Down
2 changes: 1 addition & 1 deletion 404.qmd
Expand Up @@ -2,7 +2,7 @@
title: Page Not Found
listing:
id: sample-listings
contents: content/course/**/index.qmd
contents: content/**/index.qmd
type: grid
sort: "number"
categories: true
Expand Down
117 changes: 57 additions & 60 deletions _quarto.yml
Expand Up @@ -4,10 +4,7 @@ project:
render:
- index.qmd
- content/**/*.qmd
- content/**/**/*.qmd
- content/**/**/**/*.qmd
- content/**/**/**/**/*.qmd
- "!content/slides/intro/index.qmd"
- "!content/slides/"

book:
title: "Python pour la data science"
Expand All @@ -16,21 +13,21 @@ book:
left:
- href: index.qmd
text: Home
- href: content/course/getting-started/index.qmd
- href: content/getting-started/index.qmd
text: Introduction
- href: content/course/manipulation/index.qmd
- href: content/manipulation/index.qmd
text: Manipuler des données
- href: content/course/visualisation/index.qmd
- href: content/visualisation/index.qmd
text: Visualiser des données
- href: content/course/modelisation/index.qmd
- href: content/modelisation/index.qmd
text: Modéliser
- href: content/course/NLP/index.qmd
- href: content/NLP/index.qmd
text: NLP
- href: content/course/modern-ds/index.qmd
- href: content/modern-ds/index.qmd
text: Approfondissements
- href: content/course/git/index.qmd
- href: content/git/index.qmd
text: Git {{< fa brands git-alt >}}
- href: content/course/annexes/evaluation/index.qmd
- href: content/annexes/evaluation.qmd
text: Evaluation
tools:
- icon: github
Expand Down Expand Up @@ -60,62 +57,62 @@ book:
chapters:
- href: index.qmd
text: "Homepage"
- part: "content/course/getting-started/index.qmd"
- part: "content/getting-started/index.qmd"
chapters:
- content/course/getting-started/01_installation/index.qmd
- content/course/getting-started/02_DS_environment/index.qmd
- content/course/getting-started/03_data_analysis/index.qmd
- content/course/getting-started/04_python_practice/index.qmd
- content/course/getting-started/05_rappels_types/index.qmd
- content/course/getting-started/06_rappels_fonctions/index.qmd
- content/course/getting-started/07_rappels_classes/index.qmd
- part: content/course/manipulation/index.qmd
- content/getting-started/01_installation.qmd
- content/getting-started/02_DS_environment.qmd
- content/getting-started/03_data_analysis.qmd
- content/getting-started/04_python_practice.qmd
- content/getting-started/05_rappels_types.qmd
- content/getting-started/06_rappels_fonctions.qmd
- content/getting-started/07_rappels_classes.qmd
- part: content/manipulation/index.qmd
chapters:
- content/course/manipulation/01_numpy/index.qmd
- content/course/manipulation/02a_pandas_tutorial/index.qmd
- content/course/manipulation/02b_pandas_TP/index.qmd
- content/course/manipulation/03_geopandas_tutorial/index.qmd
- content/course/manipulation/03_geopandas_TP/index.qmd
- content/course/manipulation/04a_webscraping_TP/index.qmd
- content/course/manipulation/04c_API_TP/index.qmd
- content/course/manipulation/04b_regex_TP/index.qmd
- content/course/manipulation/07_dask/index.qmd
- content/course/manipulation/06a_exo_supp_webscraping/index.qmd
- part: content/course/visualisation/index.qmd
- content/manipulation/01_numpy.qmd
- content/manipulation/02a_pandas_tutorial.qmd
- content/manipulation/02b_pandas_TP.qmd
- content/manipulation/03_geopandas_tutorial.qmd
- content/manipulation/03_geopandas_TP.qmd
- content/manipulation/04a_webscraping_TP.qmd
- content/manipulation/04c_API_TP.qmd
- content/manipulation/04b_regex_TP.qmd
- content/manipulation/07_dask.qmd
- content/manipulation/06a_exo_supp_webscraping.qmd
- part: content/visualisation/index.qmd
chapters:
- content/course/visualisation/matplotlib/index.qmd
- content/course/visualisation/maps/index.qmd
- part: content/course/modelisation/index.qmd
- content/visualisation/matplotlib.qmd
- content/visualisation/maps.qmd
- part: content/modelisation/index.qmd
chapters:
- content/course/modelisation/0_preprocessing/index.qmd
- content/course/modelisation/1_modelevaluation/index.qmd
- content/course/modelisation/2_SVM/index.qmd
- content/course/modelisation/3_regression/index.qmd
- content/course/modelisation/4_featureselection/index.qmd
- content/course/modelisation/5_clustering/index.qmd
- content/course/modelisation/6_pipeline/index.qmd
- part: content/course/NLP/index.qmd
- content/modelisation/0_preprocessing.qmd
- content/modelisation/1_modelevaluation.qmd
- content/modelisation/2_SVM.qmd
- content/modelisation/3_regression.qmd
- content/modelisation/4_featureselection.qmd
- content/modelisation/5_clustering.qmd
- content/modelisation/6_pipeline.qmd
- part: content/NLP/index.qmd
chapters:
- content/course/NLP/01_intro/index.qmd
- content/course/NLP/02_exoclean/index.qmd
- content/course/NLP/03_lda/index.qmd
- content/course/NLP/04_word2vec/index.qmd
- content/course/NLP/05_exo_supp/index.qmd
- part: content/course/modern-ds/index.qmd
- content/NLP/01_intro.qmd
- content/NLP/02_exoclean.qmd
- content/NLP/03_lda.qmd
- content/NLP/04_word2vec.qmd
- content/NLP/05_exo_supp.qmd
- part: content/modern-ds/index.qmd
chapters:
- content/course/modern-ds/continuous_integration/index.qmd
- content/course/modern-ds/dallE/index.qmd
- content/course/modern-ds/s3/index.qmd
- content/course/modern-ds/elastic_approfondissement/index.qmd
- content/course/modern-ds/elastic_intro/index.qmd
- part: content/course/git/index.qmd
- content/modern-ds/continuous_integration.qmd
- content/modern-ds/dallE.qmd
- content/modern-ds/s3.qmd
- content/modern-ds/elastic_approfondissement.qmd
- content/modern-ds/elastic_intro/index.qmd
- part: content/git/index.qmd
chapters:
- content/course/git/introgit/index.qmd
- content/course/git/exogit/index.qmd
- part: content/course/annexes/index.qmd
- content/git/introgit.qmd
- content/git/exogit.qmd
- part: content/annexes/index.qmd
chapters:
- content/course/annexes/evaluation/index.qmd
- content/course/corrections/index.qmd
- content/annexes/evaluation.qmd
- content/annexes/corrections.qmd

filters:
- lightbox
Expand Down
14 changes: 0 additions & 14 deletions build/cleanmd.py

This file was deleted.

37 changes: 0 additions & 37 deletions build/featured.py

This file was deleted.

4 changes: 0 additions & 4 deletions build/modifmd.py

This file was deleted.

35 changes: 0 additions & 35 deletions build/post-build.py

This file was deleted.

41 changes: 0 additions & 41 deletions build/tweak_markdown.py
Expand Up @@ -9,48 +9,7 @@ def read_file(filename):
s = new_text
return s

def replace_shortcode_tabs(content):
content = content.replace("\<", "<")
content = content.replace("\>", ">")
return content

def tweak_js_plotly(content):
content2 = re.sub(
r'<script type="text/javascript">\n\s*window([\S\s]*)</script>\n',
'',
content)
return content2


def write_file(filename, content):
with open(filename, 'w', encoding="utf-8") as f:
f.write(content)

def clean_write_file(fl):
content = read_file(fl)
content = re.sub(r"(“|”)",'"',content)
print(f"File: {fl}")
add_text = '\n\n<script src="https://d3js.org/d3.v7.min.js"></script>\n<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>'
yaml, text = content.split('---\n', 2)[1:]
incipit = "Ce contenu accompagne le cours [Python pour la data science](https://pythonds.linogaliana.fr/) de l'ENSAE. \n"
if re.search("plotly: true", yaml) is not None:
print(f"Tweaking {fl} using YAML header")
content = "---\n" + yaml + "---\n" \
+ "\n" + incipit + add_text + "\n" + text
else:
print(f"File {fl}: nothing to do")
if re.search(
r'<script type="text/javascript">\n\s*window.P([\S\s]*)</script>\n',
content) is not None:
print("quarto added plotly detected: removed")
content = tweak_js_plotly(content)
write_file(fl, content)


if __name__ == '__main__':
list_files = glob.glob("./content/course/**/index.md", recursive=True)
print(list_files)
[clean_write_file(fl) for fl in list_files if not fl.endswith("_index.md")]



9 changes: 6 additions & 3 deletions build/tweak_render.py
Expand Up @@ -14,14 +14,17 @@
lines = glob.glob('content/**/*.qmd', recursive=True)

lines = [l for l in lines if l.endswith('.qmd') ]
lines += [f"content/course/{dir}/index.qmd" \
for dir in ["manipulation", "visualisation", "modelisation", "NLP", "modern-ds"]
lines += [f"content/{dir}/index.qmd" \
for dir in [
"getting-started", "manipulation",
"visualisation", "modelisation",
"NLP", "modern-ds"]
]
lines += [f"index.qmd"]

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

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


print(lines2)
Expand Down
Expand Up @@ -30,11 +30,11 @@ image: wordcloud_openfood_clean.png
#| eval: true
import sys
sys.path.insert(1, '../../../../') #insert the utils module
sys.path.insert(1, '../../') #insert the utils module
from utils import print_badges
#print_badges(__file__)
print_badges("content/course/NLP/01_intro.qmd")
print_badges("content/NLP/01_intro.qmd")
```
:::

Expand Down Expand Up @@ -150,7 +150,7 @@ import requests
import PIL
import matplotlib.pyplot as plt
img = "https://raw.githubusercontent.com/linogaliana/python-datascientist/master/content/course/NLP/book.png"
img = "https://raw.githubusercontent.com/linogaliana/python-datascientist/master/content/NLP/book.png"
book_mask = np.array(PIL.Image.open(io.BytesIO(requests.get(img).content)))
fig = plt.figure()
Expand Down
Expand Up @@ -33,11 +33,11 @@ image: featured.png
#| eval: true
import sys
sys.path.insert(1, '../../../../') #insert the utils module
sys.path.insert(1, '../../') #insert the utils module
from utils import print_badges
#print_badges(__file__)
print_badges("content/course/NLP/02_exoclean.qmd")
print_badges("content/NLP/02_exoclean.qmd")
```
:::

Expand Down Expand Up @@ -231,7 +231,7 @@ Si vous ne faites pas l'exercice 1, pensez à charger les données en executant
```{python}
import requests
url = 'https://raw.githubusercontent.com/linogaliana/python-datascientist/master/content/course/NLP/get_data.py'
url = 'https://raw.githubusercontent.com/linogaliana/python-datascientist/master/content/NLP/get_data.py'
r = requests.get(url, allow_redirects=True)
open('getdata.py', 'wb').write(r.content)
Expand Down
Expand Up @@ -32,11 +32,11 @@ image: https://upload.wikimedia.org/wikipedia/commons/thumb/d/d3/Latent_Dirichle
#| eval: true
import sys
sys.path.insert(1, '../../../../') #insert the utils module
sys.path.insert(1, '../../') #insert the utils module
from utils import print_badges
#print_badges(__file__)
print_badges("content/course/NLP/03_lda.qmd")
print_badges("content/NLP/03_lda.qmd")
```
:::

Expand Down

0 comments on commit 3bdf3b0

Please sign in to comment.