Skip to content

Commit 9464829

Browse files
authored
Fix boxes now that it is better supported by jupyter (#628)
* fix problem with box * fix * intro * box exercise * Update * clean * les box * simplify pipeline
1 parent 7611f13 commit 9464829

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+1604
-10675
lines changed

.github/workflows/prod.yml

Lines changed: 43 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,43 @@ jobs:
1313
runs-on: ubuntu-latest
1414
if: ${{ !github.event.pull_request.head.repo.fork }}
1515
steps:
16+
1617
- uses: actions/checkout@v4
1718
with:
1819
fetch-depth: 0
1920
ref: ${{ github.event.pull_request.head.ref }}
2021
repository: ${{github.event.pull_request.head.repo.full_name}}
22+
2123
- name: Configure safe.directory # Workaround for actions/checkout#760
2224
run: git config --global --add safe.directory /__w/python-datascientist/python-datascientist
25+
2326
- name: Install system dependencies
2427
run: |
2528
sudo ./build/requirements.sh
26-
- name: Install the latest version of uv and set the python version to 3.13t
29+
30+
- name: Install the latest version of uv
2731
uses: astral-sh/setup-uv@v6
2832
with:
29-
python-version: "3.12"
30-
enable-cache: true
31-
cache-dependency-glob: "uv.lock"
32-
- uses: quarto-dev/quarto-actions/setup@v2
33-
- run: |
34-
quarto --version
33+
version: "latest"
34+
python-version: 3.12
35+
36+
- name: Restore environment
37+
run: uv sync
38+
39+
# Step 3: Set up Quarto
40+
- name: Set up quarto
41+
uses: quarto-dev/quarto-actions/setup@v2
42+
43+
- name: Install SpaCy corpus and check quarto version
44+
run: |
45+
uv run spacy download en_core_web_sm
46+
uv run quarto --version
47+
3548
- name: Prepare directory
3649
run: |
3750
rm _quarto.yml
3851
cp _quarto-prod.yml _quarto.yml
39-
- name: Install Python dependencies
40-
run: |
41-
uv sync
52+
4253
- name: Render website
4354
env:
4455
API_INPI_USERNAME: ${{ secrets.API_INPI_USERNAME }}
@@ -61,37 +72,49 @@ jobs:
6172
git config --global user.email quarto-github-actions-publish@example.com
6273
git config --global user.name "Quarto GHA Workflow Runner"
6374
quarto publish gh-pages . --no-render --no-browser
75+
6476
enonces:
6577
name: Render notebooks
6678
runs-on: ubuntu-latest
6779
if: ${{ !github.event.pull_request.head.repo.fork }}
6880
steps:
81+
6982
- uses: actions/checkout@v4
7083
with:
7184
fetch-depth: 0
7285
ref: ${{ github.event.pull_request.head.ref }}
7386
repository: ${{github.event.pull_request.head.repo.full_name}}
87+
7488
- name: Configure safe.directory # Workaround for actions/checkout#760
7589
run: git config --global --add safe.directory /__w/python-datascientist/python-datascientist
90+
7691
- name: Install system dependencies
7792
run: |
7893
sudo ./build/requirements.sh
79-
- name: Install the latest version of uv and set the python version to 3.13t
94+
95+
- name: Install the latest version of uv
8096
uses: astral-sh/setup-uv@v6
8197
with:
82-
python-version: "3.12"
83-
enable-cache: true
84-
cache-dependency-glob: "uv.lock"
85-
- uses: quarto-dev/quarto-actions/setup@v2
86-
- run: |
87-
quarto --version
98+
version: "latest"
99+
python-version: 3.12
100+
101+
- name: Restore environment
102+
run: uv sync
103+
104+
# Step 3: Set up Quarto
105+
- name: Set up quarto
106+
uses: quarto-dev/quarto-actions/setup@v2
107+
108+
- name: Install SpaCy corpus and check quarto version
109+
run: |
110+
uv run spacy download en_core_web_sm
111+
uv run quarto --version
112+
88113
- name: Prepare directory
89114
run: |
90115
rm _quarto.yml
91116
cp _quarto-prod.yml _quarto.yml
92-
- name: Install Python dependencies
93-
run: |
94-
uv sync
117+
95118
- name: Convert in ipynb with Quarto
96119
env:
97120
API_INPI_USERNAME: ${{ secrets.API_INPI_USERNAME }}
@@ -133,73 +156,4 @@ jobs:
133156
#target-branch: test
134157
create-target-branch-if-needed: true
135158
reset-repo: true
136-
enonces-vscode:
137-
name: Render notebooks (VSCode version)
138-
runs-on: ubuntu-latest
139-
if: ${{ !github.event.pull_request.head.repo.fork }}
140-
steps:
141-
- uses: actions/checkout@v4
142-
with:
143-
fetch-depth: 0
144-
ref: ${{ github.event.pull_request.head.ref }}
145-
repository: ${{github.event.pull_request.head.repo.full_name}}
146-
- name: Configure safe.directory # Workaround for actions/checkout#760
147-
run: |
148-
git config --global --add safe.directory /__w/python-datascientist/python-datascientist
149-
git config --global --add safe.directory /__w/python-datascientist/python-datascientist-notebooks-vscode
150-
- name: Install system dependencies
151-
run: |
152-
sudo ./build/requirements.sh
153-
- name: Install the latest version of uv and set the python version to 3.13t
154-
uses: astral-sh/setup-uv@v6
155-
with:
156-
python-version: "3.12"
157-
enable-cache: true
158-
cache-dependency-glob: "uv.lock"
159-
- uses: quarto-dev/quarto-actions/setup@v2
160-
- run: |
161-
quarto --version
162-
- name: Prepare directory
163-
run: |
164-
rm _quarto.yml
165-
cp _quarto-prod.yml _quarto.yml
166-
- name: Install Python dependencies
167-
run: |
168-
uv sync
169-
- name: Convert in ipynb with Quarto
170-
env:
171-
API_INPI_USERNAME: ${{ secrets.API_INPI_USERNAME }}
172-
API_INPI_PASSWORD: ${{ secrets.API_INPI_PASSWORD }}
173-
run: |
174-
export QUARTO_PROFILE=fr,en
175-
cp _quarto.yml _quarto-prod.yml
176-
uv run ./build/nice-vscode/tweak_pipeline_vscode.py --filename _quarto-prod.yml
177-
cp _quarto-prod2.yml _quarto.yml
178-
rm content/modelisation/index.qmd # Remove file not building in ipynb
179-
uv run quarto render --profile fr --to ipynb
180-
uv run quarto render --profile en --to ipynb
181-
- name: Move to expected directory
182-
env:
183-
API_INPI_USERNAME: ${{ secrets.API_INPI_USERNAME }}
184-
API_INPI_PASSWORD: ${{ secrets.API_INPI_PASSWORD }}
185-
run: |
186-
mkdir -p temp_notebooks
187-
mkdir -p temp_notebooks/notebooks
188-
uv run build/move_files.py --direction temp_notebooks/notebooks
189-
uv run quarto render content --to ipynb --execute -M echo:true
190-
mkdir -p temp_notebooks/corrections
191-
uv run build/move_files.py --direction temp_notebooks/corrections
192-
- name: Pushes to another repository
193-
uses: linogaliana/github-action-push-to-another-repository@main
194-
env:
195-
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
196-
with:
197-
source-directory: 'temp_notebooks/'
198-
destination-repository-username: 'linogaliana'
199-
destination-repository-name: 'python-datascientist-notebooks-vscode'
200-
user-email: lino.galiana@insee.fr
201-
destination-github-username: linogaliana
202-
#target-branch: test
203-
create-target-branch-if-needed: true
204-
reset-repo: true
205159

_quarto.yml

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,45 @@ project:
44
- index.qmd
55
- 404.qmd
66
- content/getting-started/index.qmd
7+
- content/getting-started/01_environment.qmd
8+
- content/getting-started/02_data_analysis.qmd
9+
- content/getting-started/03_revisions.qmd
10+
- content/manipulation/index.qmd
11+
- content/manipulation/01_numpy.qmd
12+
- content/manipulation/02_pandas_intro.qmd
13+
- content/manipulation/02_pandas_suite.qmd
14+
- content/manipulation/02a_pandas_tutorial.qmd
15+
- content/manipulation/02b_pandas_TP.qmd
16+
- content/manipulation/03_geopandas_intro.qmd
17+
- content/manipulation/03_geopandas_tutorial.qmd
18+
- content/manipulation/03_geopandas_TP.qmd
19+
- content/manipulation/04a_webscraping_TP.qmd
20+
- content/manipulation/04c_API_TP.qmd
21+
- content/manipulation/04b_regex_TP.qmd
722
- content/manipulation/05_parquet_s3.qmd
23+
- content/visualisation/index.qmd
24+
- content/visualisation/matplotlib.qmd
25+
- content/visualisation/maps.qmd
26+
- content/modelisation/index.qmd
27+
- content/modelisation/0_preprocessing.qmd
28+
- content/modelisation/1_modelevaluation.qmd
29+
- content/modelisation/2_classification.qmd
30+
- content/modelisation/3_regression.qmd
31+
- content/modelisation/4_featureselection.qmd
32+
- content/modelisation/5_clustering.qmd
33+
- content/modelisation/6_pipeline.qmd
34+
- content/modelisation/7_mlapi.qmd
35+
- content/NLP/index.qmd
36+
- content/NLP/01_intro.qmd
37+
- content/NLP/02_exoclean.qmd
38+
- content/NLP/03_embedding.qmd
39+
- content/modern-ds/s3.qmd
40+
- content/git/index.qmd
41+
- content/git/introgit.qmd
42+
- content/git/exogit.qmd
43+
- content/annexes/about.qmd
44+
- content/annexes/evaluation.qmd
45+
- content/annexes/corrections.qmd
846

947
profile:
1048
default: fr
@@ -69,11 +107,9 @@ format:
69107
# PAGE OPTIONS ---------------------
70108

71109
filters:
110+
- include-code-files
72111
- build/replace-title.lua
73112
- build/lang-notebook.lua
74-
- black-formatter
75-
- build/callout/callout-jupyter.lua
76-
- include-code-files
77113
- _extensions/linogaliana/details-iframe/details.lua
78114
- _extensions/linogaliana/lang-switch/button.lua
79115

@@ -89,6 +125,7 @@ keep-ipynb: true
89125
lightbox: auto
90126
google-scholar: true
91127
highlight-style: a11y
128+
92129
#author: Lino Galiana
93130
#date: today
94131
#page-layout: article

build/callout/callout-jupyter.lua

Lines changed: 48 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,52 @@
11
function createCallout(div, type)
2-
local customIcons = {
3-
exercise = "<i class=\"fa-solid fa-pencil\"></i>",
4-
note = "<i class=\"fa-solid fa-comment\"></i>",
5-
tip = "<i class=\"fa-solid fa-lightbulb\"></i>",
6-
warning = "<i class=\"fa-solid fa-triangle-exclamation\"></i>",
7-
important = "<i class=\"fa-solid fa-triangle-exclamation\"></i>"
8-
}
9-
local customColor = {
10-
note = "info",
11-
tip = "success",
12-
exercise = "success",
13-
warning = "danger",
14-
important = "danger"
15-
}
16-
17-
local title = type:gsub("^%l", string.upper)
18-
-- Use first element of div as title if this is a header
19-
if div.content[1] ~= nil and div.content[1].t == "Header" then
20-
title = pandoc.utils.stringify(div.content[1])
21-
div.content:remove(1)
22-
end
23-
24-
local icon = customIcons[type] or ""
25-
local color = customColor[type] or ""
26-
27-
if quarto.doc.is_format("ipynb") then
28-
if type == "exercise" then
29-
type = "tip"
30-
icon = customIcons["exercise"]
31-
end
32-
-- Add html formatting around
33-
local headBox = "<div class=\"alert alert-" .. color .. "\" role=\"alert\">\n" ..
34-
"<h3 class=\"alert-heading\">" .. icon .. " " .. title .. "</h3>\n"
35-
36-
-- Insert raw HTML blocks
37-
div.content:insert(1, pandoc.RawBlock('html', headBox .. "\n"))
38-
div.content:insert(pandoc.RawBlock('html', "\n</div>"))
39-
return div
40-
else
41-
local old_attr = div.attr
42-
local appearanceRaw = div.attr.attributes["appearance"]
43-
local collapse = div.attr.attributes["collapse"]
44-
return quarto.Callout({
45-
type = type,
46-
title = title,
47-
collapse = false,
48-
content = div.content,
49-
icon = icon
50-
})
51-
end
2+
local customIcons = {
3+
exercise = "<i class=\"fa-solid fa-pencil\"></i>",
4+
note = "<i class=\"fa-solid fa-comment\"></i>",
5+
tip = "<i class=\"fa-solid fa-lightbulb\"></i>",
6+
warning = "<i class=\"fa-solid fa-triangle-exclamation\"></i>",
7+
important = "<i class=\"fa-solid fa-triangle-exclamation\"></i>"
8+
}
9+
10+
local customColor = {
11+
note = "info",
12+
tip = "success",
13+
exercise = "success",
14+
warning = "danger",
15+
important = "danger"
16+
}
17+
18+
local title = type:gsub("^%l", string.upper)
19+
20+
-- Use first element of div as title if it is a Header
21+
if div.content[1] ~= nil and div.content[1].t == "Header" then
22+
title = pandoc.utils.stringify(div.content[1])
23+
div.content:remove(1)
24+
end
25+
26+
local icon = customIcons[type] or ""
27+
local color = customColor[type] or ""
28+
29+
-- Add HTML formatting for ipynb output
30+
local headBox = "<div class=\"alert alert-" .. color .. "\" role=\"alert\">\n" ..
31+
"<h3 class=\"alert-heading\">" .. icon .. " " .. title .. "</h3>\n"
32+
33+
div.content:insert(1, pandoc.RawBlock('html', headBox))
34+
div.content:insert(pandoc.RawBlock('html', "</div>"))
35+
36+
return div
37+
end
38+
39+
function Div(div)
40+
if not quarto.doc.is_format("ipynb") then
41+
return nil
5242
end
53-
54-
function Div(div)
55-
-- List of supported callout types
56-
local callout_types = {"note", "caution", "warning", "important", "tip", "exercise"}
57-
58-
for _, type in ipairs(callout_types) do
59-
if div.classes:includes(type) then
60-
return createCallout(div, type)
61-
end
43+
44+
-- List of base callout types
45+
local baseTypes = { "note", "caution", "warning", "important", "tip", "exercise" }
46+
47+
for _, type in ipairs(baseTypes) do
48+
if div.classes:includes(type) or div.classes:includes("callout-" .. type) then
49+
return createCallout(div, type)
6250
end
6351
end
64-
52+
end

0 commit comments

Comments
 (0)