-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: creation d'un dossier dedié au module 1 * feat: ajout de tous les chapitres actuels du module 1 dans un dossier dédié, modif du _toc pour en faire une section * feat: re-enumeration des chapitres * fix: typos * fix: renomme les chapitres avec deux chiffres par numéros * feat: réécriture du chapitre 3 * feat: début chap 3 OK + sauvegarde gradient descent * feat: fin du chapitre 3! * feat: les sources sont proprement affichées * feat: plotly support and plotly figures for chap 3 * feat: now delete old iframes before generating the new one during compilation * [CICD] Add copy iframes step to pipeline * Fix: call python script correctly * Fix : copy iframes using right versions of dependencies * IAZLogger for DevOps scripting Co-authored-by: PierrotLC <[email protected]> Co-authored-by: Pierre Pereira <[email protected]> Co-authored-by: Lucas Pauzies <[email protected]>
- Loading branch information
1 parent
b7cefe5
commit 1ad50e1
Showing
27 changed files
with
1,369 additions
and
1,338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import os | ||
import shutil | ||
import logging | ||
from argparse import ArgumentParser | ||
from typing import Callable | ||
from utils.iaz_logger import IAZLogger | ||
|
||
# Logger setup | ||
logger = IAZLogger() | ||
|
||
# Script constants | ||
IFRAMES_FOLDER = "iframe_figures" | ||
|
||
def create_parser() -> ArgumentParser: | ||
parser = ArgumentParser() | ||
parser.add_argument("root_directory", help="The root directory where '_build' folder exists as output from 'jupyter-book' build step.") | ||
parser.add_argument("current_directory", help=f"The current directory from where you want to search for '{IFRAMES_FOLDER}' folders recursively.") | ||
return parser | ||
|
||
def copy_iframes(current_directory: str, root_directory: str, verbose: bool = True) -> None: | ||
"""Copy iframes from 'current_directory' to build directory of 'jupyter-book' command. | ||
Args: | ||
current_directory (str): Path of the directory which contains a subdirectory `iframe_figures`. | ||
root_directory (str): Path of the root directory, where the website is build. | ||
verbose (bool, optional): Verbose of the function. Defaults to True. | ||
""" | ||
# Let the function raise exceptions if no 'iframe_figures' directory found. | ||
if IFRAMES_FOLDER not in os.listdir(current_directory): | ||
logger.warning("No iframes in %s", current_directory) | ||
return | ||
|
||
# Define absolute path of iframes folder as it should be | ||
absolute_current_directory = os.path.abspath(current_directory) | ||
absolute_iframes_folder = os.path.join(absolute_current_directory, IFRAMES_FOLDER) | ||
if verbose: logger.info("Built iframes absolute path : '%s'.", absolute_iframes_folder) | ||
# Define absolute root directory as it should be | ||
absolute_root_directory = os.path.abspath(root_directory) | ||
if verbose: logger.info("Built root absolute path : '%s'.", absolute_root_directory) | ||
# Find common path in absolute directories | ||
common_path = os.path.commonpath([absolute_iframes_folder, absolute_root_directory]) | ||
complete_path = absolute_iframes_folder.split(common_path)[-1] | ||
website_path = f"{os.path.join(absolute_root_directory, '_build', 'html')}{complete_path}" | ||
if verbose: logger.info("Define website path where to make the copy : '%s'.", website_path) | ||
logger.info("Copying '%s' to %s", absolute_iframes_folder, website_path) | ||
#shutil.copytree(absolute_iframes_folder, website_path) | ||
logger.info("Copied sucessfully to '%s'.", website_path) | ||
|
||
def apply_recursive(current_directory: str, applied_function: Callable[[str], None]) -> None: | ||
"""Check recursively if 'iframe_figures' is in the 'current_directory'. | ||
If so, call the function `applied_function` with the path of the directory containing 'iframe_figures. | ||
If not, call this function recursively on all child directories. | ||
Args: | ||
current_directory (str): Path of the directory where we look for an 'iframe_figures' subdirectory. | ||
applied_function (Callable): Function to call when we find an 'iframe_figures'. | ||
""" | ||
current_directory_subdirectories = [ dirname for dirname in os.listdir(current_directory) if os.path.isdir(os.path.join(current_directory, dirname)) ] | ||
for directory_name in current_directory_subdirectories: | ||
if directory_name == IFRAMES_FOLDER: applied_function(current_directory) | ||
else: apply_recursive(os.path.join(current_directory, directory_name), applied_function) | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = create_parser() | ||
args = parser.parse_args() | ||
root_directory = args.root_directory | ||
current_directory = args.current_directory | ||
apply_recursive(current_directory, lambda walking_directory: copy_iframes(walking_directory, root_directory)) | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import logging | ||
|
||
from colorlog import ColoredFormatter | ||
|
||
class IAZLogger(logging.Logger): | ||
|
||
def __init__(self, name: str = "IAZ Logger", level: int = logging.INFO) -> None: | ||
super().__init__(name, level) | ||
logger_format = "%(asctime)s [%(levelname)s] %(message)s" | ||
console_handler = logging.StreamHandler() | ||
console_handler.setLevel(level) | ||
console_handler.setFormatter(ColoredFormatter(logger_format, force_color=True)) | ||
self.addHandler(console_handler) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,6 @@ _build/ | |
venv/ | ||
|
||
.DS_Store | ||
|
||
# Notebook outputs | ||
**/iframe_figures/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#! /usr/bin/bash | ||
rm -rf ./_build | ||
python3 manage_iframes.py delete ./docs/ | ||
jupyter-book build . | ||
python3 manage_iframes.py copy ./docs/ . |
1,222 changes: 0 additions & 1,222 deletions
1,222
docs/Cours fondamentaux ML/3 - Regression lineaire.ipynb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.