Skip to content

Commit

Permalink
Simplify badges generation (#130)
Browse files Browse the repository at this point in the history
A shortfunction to automatically print badges for exercises when needed

Almost solved #117. Problem with relative link in https://linogaliana-teaching.netlify.app/course/listetp/

* print badhes

* Automated changes

* rm utterance tempor

* Automated changes

* modif debut

* Automated changes

* ajoute badge

* Automated changes

* ajoute badges

* modif badge

* modif badges

* Automated changes

* include badges

* Automated changes

* eval TRUE badges

* Automated changes

* retour version light

* Automated changes

* update badges

* ajoute option

* modif liens

* Automated changes

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
linogaliana and github-actions[bot] committed Sep 2, 2021
1 parent bf5ebc5 commit 2e4d586
Show file tree
Hide file tree
Showing 28 changed files with 187 additions and 103 deletions.
25 changes: 24 additions & 1 deletion .Rprofile
Expand Up @@ -26,9 +26,13 @@ badge <- function(type = "onyxia"){
}



reminder_badges <- function(notebook = ""){

if (notebook != ""){
if (!endsWith(notebook, ".ipynb")){
notebook <- paste0(notebook, ".ipynb")
}
github_link <- 'https://github.com/linogaliana/python-datascientist/blob/master'
binder_path <- paste0("?filepath=",notebook)
notebook <- paste0('/', notebook)
Expand All @@ -49,7 +53,7 @@ reminder_badges <- function(notebook = ""){
"[![nbviewer](https://img.shields.io/badge/visualize-nbviewer-blue)](",
nbviewer_link,")"
)
onyxia_link <- "[![Onyxia](https://img.shields.io/badge/launch-onyxia-brightgreen)](https://datalab.sspcloud.fr/my-lab/catalogue/inseefrlab-helm-charts-datascience/jupyter/deploiement?resources.requests.memory=4096Mi)"
onyxia_link <- "[![Onyxia](https://img.shields.io/badge/SSPcloud-Tester%20via%20SSP--cloud-informational&color=yellow?logo=Python)](https://datalab.sspcloud.fr/launcher/inseefrlab-helm-charts-datascience/jupyter?onyxia.friendlyName=%C2%ABpython-datascientist%C2%BB&resources.requests.memory=%C2%AB4Gi%C2%BB)"
binder_link <- sprintf(
"[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/linogaliana/python-datascientist/master%s)",
binder_path
Expand All @@ -73,6 +77,25 @@ reminder_badges <- function(notebook = ""){
}


print_badges <- function(fpath = NULL){
if (is.null(fpath)){
fpath <- knitr::current_input(dir = TRUE)
}
fpath <- gsub(paste0(here::here(),"/./"), "", fpath)
fpath <- gsub("Rmd", "ipynb", fpath)
fpath <- gsub("content","notebooks",fpath)
reminder_badges(fpath)
}

github_link <- function(fpath = NULL){
if (is.null(fpath)){
fpath <- knitr::current_input(dir = TRUE)
}
fpath <- gsub(paste0(here::here(),"/./"), "", fpath)
fpath <- gsub("Rmd", "ipynb", fpath)
fpath <- gsub("content","notebooks",fpath)
return(fpath)
}


reminder_box <- function(boxtype = "warning", type = c("html","markdown")){
Expand Down
4 changes: 2 additions & 2 deletions build/build_light.R
@@ -1,7 +1,7 @@
content_rmd <- list.files("./content", recursive = TRUE, pattern = "*.Rmd", full.names = TRUE)
content_rmd <- list.files("./content", recursive = TRUE, pattern = "*.Rmd", full.names = TRUE)
content_rmd <- content_rmd[!grepl("/git/", content_rmd)]
content_rmd <- content_rmd[!grepl("06a_exo_supp_webscraping.", content_rmd)]
content_rmd <- content_rmd[6]
content_rmd <- content_rmd[5]

file.remove(
gsub(
Expand Down
2 changes: 1 addition & 1 deletion config/_default/params.toml
Expand Up @@ -140,7 +140,7 @@ plugins_js = ["custom"]
# "": Disabled
# "disqus": Disqus (https://disqus.com)
# "commento": Commento (https://commento.io)
provider = "utterances"
provider = ""

# Which page types are commentable?
commentable = {book = true}
Expand Down
4 changes: 4 additions & 0 deletions content/course/NLP/01_intro.Rmd
Expand Up @@ -59,6 +59,10 @@ knitr::knit_hooks$set(
```

```{r, echo = FALSE, results = 'asis', include = TRUE, eval = TRUE}
print_badges()
```



{{% panel status="warning" title="Warning" icon="fa fa-exclamation-triangle" %}}
Expand Down
4 changes: 4 additions & 0 deletions content/course/NLP/02_exoclean.Rmd
Expand Up @@ -59,6 +59,10 @@ knitr::knit_hooks$set(
```

```{r, echo = FALSE, results = 'asis', include = TRUE, eval = TRUE}
print_badges()
```



Cette page approfondit certains aspects présentés dans la
Expand Down
4 changes: 4 additions & 0 deletions content/course/NLP/03_lda.Rmd
Expand Up @@ -60,6 +60,10 @@ knitr::knit_hooks$set(
```

```{r, echo = FALSE, results = 'asis', include = TRUE, eval = TRUE}
print_badges()
```




Expand Down
4 changes: 4 additions & 0 deletions content/course/NLP/04_word2vec.Rmd
Expand Up @@ -61,6 +61,10 @@ knitr::knit_hooks$set(
```

```{r, echo = FALSE, results = 'asis', include = TRUE, eval = TRUE}
print_badges()
```


Cette page approfondit certains aspects présentés dans la
[partie introductive](#nlp). Après avoir travaillé sur le
Expand Down
6 changes: 5 additions & 1 deletion content/course/NLP/05_exo_supp.Rmd
Expand Up @@ -58,6 +58,10 @@ knitr::knit_hooks$set(
```

```{r, echo = FALSE, results = 'asis', include = TRUE, eval = TRUE}
print_badges()
```

Cette page approfondit certains aspects présentés dans les autres tutoriels. Il s'agit d'une suite d'exercice, avec corrections, pour présenter d'autres aspects du NLP ou pratiquer sur des données différentes


Expand Down Expand Up @@ -277,4 +281,4 @@ x
Un exercice à venir sur l'analyse des discours des présidents américains
inspiré de https://github.com/BuzzFeedNews/2018-01-trump-state-of-the-union
---->
---->
60 changes: 60 additions & 0 deletions content/course/listeTP/_index.Rmd
@@ -0,0 +1,60 @@
---
title: "Travaux dirigés"
date: 2020-09-10T13:00:00Z
draft: false
weight: 80
icon: pencil-alt
icon_pack: fas
#linktitle: "Partie 4: Natural Language Processing (NLP)"
summary: |
Une liste des TD sous format notebook
type: book
---

La liste des travaux dirigés, sous forme d'exercices approfondis, peut être
trouvée ci-dessous. A chaque fois, la première ligne rappelle l'objet du TP
(et renvoie vers la page web dédiée),
et la seconde propose un certain nombre de boutons permettant de visualiser
ou exécuter ces notebooks dans un environnement
temporaire (voir [ici](#configuration)).

Séance 1:

* [Des rappels généraux sur les objets en python](#rappels2A)
```{r, echo = FALSE, results = 'asis', include = TRUE, eval = TRUE}
print_badges("content/course/getting-started/05_rappels_types.Rmd")
```

* [Des rappels sur les fonctions en python](#rappelsfonctions)
```{r, echo = FALSE, results = 'asis', include = TRUE, eval = TRUE}
print_badges("content/course/getting-started/06_rappels_fonctions.Rmd")
```


* [Un TD (optionnel) sur les classes en python](#rappelsclasses)
```{r, echo = FALSE, results = 'asis', include = TRUE, eval = TRUE}
print_badges("content/course/getting-started/07_rappels_classes.Rmd")
```

* [Une découverte de numpy](#numpy)
```{r, echo = FALSE, results = 'asis', include = TRUE, eval = TRUE}
print_badges("content/course/manipulation/01_numpy.Rmd")
```


Séance 2:

* [Découverte de pandas par l'exemple](#pandasTP)
```{r, echo = FALSE, results = 'asis', include = TRUE, eval = TRUE}
print_badges("content/course/manipulation/02b_pandas_TP.Rmd")
```


Séance 3:

* [Découverte de geopandas par l'exemple](#geopandasTP)
```{r, echo = FALSE, results = 'asis', include = TRUE, eval = TRUE}
print_badges("content/course/manipulation/02b_geopandas_TP.Rmd")
```

Séance 4: **TO BE UPDATED**
75 changes: 0 additions & 75 deletions content/course/listeTP/_index.md

This file was deleted.

14 changes: 7 additions & 7 deletions content/course/manipulation/01_numpy.Rmd
Expand Up @@ -28,12 +28,11 @@ summary: |
d'aller plus loin.
---

<!---- reminder_badges("content/manipulation/01_tp_numpy.ipynb") --->
<a href="https://github.com/linogaliana/python-datascientist/blob/master/content/manipulation/01_tp_numpy.ipynb" class="github"><i class="fab fa-github"></i></a>
[![nbviewer](https://img.shields.io/badge/visualize-nbviewer-blue)](https://nbviewer.jupyter.org/github/linogaliana/python-datascientist/blob/master/content/manipulation/01_tp_numpy.ipynb)
[![Onyxia](https://img.shields.io/badge/SSPcloud-Tester%20via%20SSP--cloud-informational&color=yellow?logo=Python)](https://datalab.sspcloud.fr/launcher/inseefrlab-helm-charts-datascience/jupyter?onyxia.friendlyName=%C2%ABpython-datascientist%C2%BB&resources.requests.memory=%C2%AB4Gi%C2%BB)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/linogaliana/python-datascientist/master?filepath=content/manipulation/01_tp_numpy.ipynb)
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](http://colab.research.google.com/github/linogaliana/python-datascientist/blob/master/content/manipulation/01_tp_numpy.ipynb)


```{r, echo = FALSE, results = 'asis', include = TRUE, eval = TRUE}
print_badges()
```

```{r setup, include=FALSE}
library(knitr)
Expand All @@ -42,6 +41,7 @@ knitr::knit_engines$set(python = reticulate::eng_python)
```



Il est recommandé de régulièrement se référer à
la [cheatsheet numpy](https://www.datacamp.com/community/blog/python-numpy-cheat-sheet) et à la
[doc officielle](https://numpy.org/doc/stable/) en cas de doute
Expand Down Expand Up @@ -576,4 +576,4 @@ M = np.array([[0, 0, 0, 0, 1],
[0, 1, 0.5, 0, 0],
[0, 0, 0.5, 1, 0]])
v = pagerank(M, 100, 0.85)
```
```
15 changes: 8 additions & 7 deletions content/course/manipulation/02a_pandas_tutorial.Rmd
Expand Up @@ -32,13 +32,6 @@ summary: |
(PostgresQL, Dask, Spark...).
---

Pour visualiser le [TP associé à ce tutoriel](pandasTP) :
<!---- reminder_badges("content/manipulation/02_pandas_tp.ipynb") --->
<a href="https://github.com/linogaliana/python-datascientist/blob/master/content/manipulation/notebooks/02_pandas_tp.ipynb" class="github"><i class="fab fa-github"></i></a>
[![nbviewer](https://img.shields.io/badge/visualize-nbviewer-blue)](https://nbviewer.jupyter.org/github/linogaliana/python-datascientist/blob/master/content/manipulation/notebooks/02_pandas_tp.ipynb)
[![Onyxia](https://img.shields.io/badge/SSPcloud-Tester%20via%20SSP--cloud-informational&color=yellow?logo=Python)](https://datalab.sspcloud.fr/launcher/inseefrlab-helm-charts-datascience/jupyter?onyxia.friendlyName=%C2%ABpython-datascientist%C2%BB&resources.requests.memory=%C2%AB4Gi%C2%BB)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/linogaliana/python-datascientist/master?filepath=content/manipulation/notebooks/02_pandas_tp.ipynb)
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](http://colab.research.google.com/github/linogaliana/python-datascientist/blob/master/content/manipulation/notebooks/02_pandas_tp.ipynb)

```{r setup, include=FALSE}
dir_path <- gsub(here::here(), "..", here::here("course","manipulation"))
Expand Down Expand Up @@ -70,6 +63,14 @@ knitr::knit_hooks$set(
```

Pour essayer les exemples présents dans ce tutoriel :

```{r, echo = FALSE, results = 'asis', include = TRUE, eval = TRUE}
print_badges()
```

Le [chapitre suivant](#pandasTP) permettra de pratiquer plus amplement les
concepts

Dans ce tutoriel `pandas`, nous allons utiliser:

Expand Down
6 changes: 6 additions & 0 deletions content/course/manipulation/02b_pandas_TP.Rmd
Expand Up @@ -36,6 +36,12 @@ knitr::knit_engines$set(python = reticulate::eng_python)
knitr::opts_chunk$set(echo = FALSE)
```

Les exemples de ce TP sont visualisables sous forme de notebooks:

```{r, echo = FALSE, results = 'asis', include = TRUE, eval = TRUE}
print_badges()
```


Dans ce tutoriel `pandas`, nous allons utiliser deux sources de données :

Expand Down
4 changes: 4 additions & 0 deletions content/course/manipulation/03_geopandas_TP.Rmd
Expand Up @@ -35,6 +35,10 @@ knitr::knit_engines$set(python = reticulate::eng_python)
knitr::opts_chunk$set(eval = FALSE, include = FALSE, echo = FALSE)
```

```{r, echo = FALSE, results = 'asis', include = TRUE, eval = TRUE}
print_badges()
```


```{python, echo = TRUE}
import geopandas as gpd
Expand Down
4 changes: 3 additions & 1 deletion content/course/manipulation/03_geopandas_tutorial.Rmd
Expand Up @@ -60,7 +60,9 @@ knitr::knit_hooks$set(
```


```{r, echo = FALSE, results = 'asis', include = TRUE, eval = TRUE}
print_badges()
```

Dans ce tutoriel, nous allons utiliser:

Expand Down
3 changes: 3 additions & 0 deletions content/course/manipulation/04a_webscraping_TP.Rmd
Expand Up @@ -35,6 +35,9 @@ knitr::knit_engines$set(python = reticulate::eng_python)
knitr::opts_chunk$set(eval = FALSE)
```

```{r, echo = FALSE, results = 'asis', include = TRUE, eval = TRUE}
print_badges()
```

Sous ce nom se cache une pratique très utile pour toute personne souhaitant travailler sur des informations disponibles en ligne, mais n'existant pas forcément sous la forme d'un tableau *Excel*... Bref, il s'agit de récupérer des informations depuis *Internet*.

Expand Down
4 changes: 4 additions & 0 deletions content/course/manipulation/04b_regex_TP.Rmd
Expand Up @@ -28,6 +28,10 @@ summary: |
notamment pour les tâches de traitement naturel du langage (NLP)
---

```{r, echo = FALSE, results = 'asis', include = TRUE, eval = TRUE}
print_badges()
```


Chercher un mot dans un texte est une tâche facile, c'est l'objectif de la méthode find attachée aux chaînes de caractères, elle suffit encore lorsqu'on cherche un mot au pluriel ou au singulier mais il faut l'appeler au moins deux fois pour chercher ces deux formes.

Expand Down

0 comments on commit 2e4d586

Please sign in to comment.