Skip to content

Commit

Permalink
abandon CI to automatically document course on SSP Cloud training sec…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
avouacr committed Sep 2, 2022
1 parent 688cc15 commit cb1cfef
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 60 deletions.
33 changes: 0 additions & 33 deletions .github/workflows/update-doc-sspcloud.yaml

This file was deleted.

7 changes: 5 additions & 2 deletions sspcloud/METADATA.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"types": ["Notebook Python"],
"tags": ["consolidate", "learn"],
"category": "training courses with python",
"imageUrl": "https://raw.githubusercontent.com/InseeFrLab/www.sspcloud.fr/main/src/app/assets/img/python.jpg",
"imageUrl": "https://raw.githubusercontent.com/InseeFrLab/www.sspcloud.fr/main/src/assets/img/python.jpg",
"sections": {
"manipulation": {
"name": "Manipulation de données",
Expand All @@ -15,8 +15,11 @@
"02a_pandas_tutorial",
"02b_pandas_TP",
"03_geopandas_tutorial",
"03_geopandas_TP",
"04a_webscraping_TP",
"04c_API_TP"
"04b_regex_TP",
"04c_API_TP",
"06a_exo_supp_webscraping"
]
},
"visualisation": {
Expand Down
41 changes: 19 additions & 22 deletions sspcloud/generate-doc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Generate doc of a training program for https://www.sspcloud.fr."""
import logging
import os
from os.path import dirname
import json
Expand All @@ -19,11 +18,11 @@ def extract_metadata_md(md_path):
def generate_block(name, abstract, authors, types, tags, category,
img_url, article_url=None, deployment_url=None):
"""Generate json documentation for a training program block.
If both `article_url` and `deployment_url` are None, the block is assumed
to be a container for further sub-blocks (i.e. has an "open" button).
Otherwise, either one of or both `article_url` and `deployment_url` must
be provided.
be provided.
"""
block = {
"name": name,
Expand Down Expand Up @@ -53,20 +52,20 @@ def generate_block(name, abstract, authors, types, tags, category,
md = json.load(file)

# Main URLs
LAUNCHER_TMPLT = ("https://datalab.sspcloud.fr/launcher/inseefrlab-helm-charts-datascience/jupyter"
LAUNCHER_TMPLT = ("https://datalab.sspcloud.fr/launcher/ide/jupyter"
"?autoLaunch=true&onyxia.friendlyName=%C2%ABpython-datascience%C2%BB"
"&init.personalInit=%C2%ABhttps%3A%2F%2Fraw.githubusercontent.com%2Flinogaliana%2Fpython-datascientist%2Fmaster%2Fsspcloud%2Finit-jupyter.sh%C2%BB"
"&init.personalInitArgs=%C2%AB{init_args}%C2%BB"
"&security.allowlist.enabled=false")
COURSE_NAME_ENCODED = urllib.parse.quote(md['name'])

# Build documentation's top block
doc_json = generate_block(name=md["name"],
abstract=md["abstract"],
authors=md["authors"],
types=md["types"],
tags=md["tags"],
category=md["category"],
doc_json = generate_block(name=md["name"],
abstract=md["abstract"],
authors=md["authors"],
types=md["types"],
tags=md["tags"],
category=md["category"],
img_url=md["imageUrl"]
)
for section in md["sections"].keys():
Expand All @@ -75,7 +74,7 @@ def generate_block(name, abstract, authors, types, tags, category,
section_doc = generate_block(name=section_md["name"],
abstract=section_md["abstract"],
authors=md["authors"],
types=md["types"],
types=md["types"],
tags=md["tags"],
category=md["category"],
img_url=md["imageUrl"]
Expand All @@ -92,14 +91,14 @@ def generate_block(name, abstract, authors, types, tags, category,
launcher_url = LAUNCHER_TMPLT.format(init_args=init_args)

chapter_doc = generate_block(name=name,
abstract=abstract,
authors=md["authors"],
types=md["types"],
tags=md["tags"],
category=md["category"],
img_url=md["imageUrl"],
deployment_url=launcher_url
)
abstract=abstract,
authors=md["authors"],
types=md["types"],
tags=md["tags"],
category=md["category"],
img_url=md["imageUrl"],
deployment_url=launcher_url
)
section_doc["parts"].append(chapter_doc)

else:
Expand All @@ -109,6 +108,4 @@ def generate_block(name, abstract, authors, types, tags, category,

# Export to json
with open(os.path.join(PROJECT_DIR, "doc.json"), "w") as json_file:
json.dump(doc_json, json_file,
# indent=4 # For test only
)
json.dump(doc_json, json_file, indent=2, ensure_ascii=False)
7 changes: 4 additions & 3 deletions sspcloud/init-jupyter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ IFS=/ read -r SECTION CHAPTER <<< $RELPATH
echo $SECTION
echo $CHAPTER

WORK_DIR=/home/jovyan/work
WORK_DIR=/home/onyxia/work
CLONE_DIR=${WORK_DIR}/repo-git
COURSE_DIR=${CLONE_DIR}/notebooks/course
FORMATION_DIR=${WORK_DIR}/formation
Expand All @@ -26,10 +26,11 @@ mkdir $FORMATION_DIR
cp ${COURSE_DIR}/${SECTION}/${CHAPTER} ${FORMATION_DIR}/

# Give write permissions
chown -R jovyan:users $FORMATION_DIR
chown -R onyxia:users $FORMATION_DIR

# Remove course Git repository
rm -r $CLONE_DIR

# Open the relevant notebook when starting Jupyter Lab
echo "c.LabApp.default_url = '/lab/tree/formation/${CHAPTER}'" >> /home/jovyan/.jupyter/jupyter_server_config.py
jupyter server --generate-config
echo "c.LabApp.default_url = '/lab/tree/formation/${CHAPTER}'" >> /home/onyxia/.jupyter/jupyter_server_config.py

0 comments on commit cb1cfef

Please sign in to comment.