Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ogs
ogs
Commits
0f7e7832
Verified
Commit
0f7e7832
authored
1 year ago
by
Lars Bilke
Browse files
Options
Downloads
Patches
Plain Diff
[ci] Jupytext notebooks can be downloaded as ipynb from the website.
parent
b8194102
No related branches found
No related tags found
1 merge request
!4704
[Web] Tutorial of creating mesh with BHEs and enhanced notebook to web conversion
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tests/Data/Notebooks/testrunner.py
+29
-17
29 additions, 17 deletions
Tests/Data/Notebooks/testrunner.py
with
29 additions
and
17 deletions
Tests/Data/Notebooks/testrunner.py
+
29
−
17
View file @
0f7e7832
...
@@ -119,6 +119,7 @@ for notebook_file_path in args.notebooks:
...
@@ -119,6 +119,7 @@ for notebook_file_path in args.notebooks:
if
juyptext
:
if
juyptext
:
nb
=
jupytext
.
read
(
notebook_file_path
)
nb
=
jupytext
.
read
(
notebook_file_path
)
convert_notebook_file
=
convert_notebook_file
.
replace
(
"
notebook-
"
,
""
)
convert_notebook_file
=
convert_notebook_file
.
replace
(
"
notebook-
"
,
""
)
jupytext
.
write
(
nb
,
convert_notebook_file
)
else
:
else
:
with
open
(
notebook_file_path
,
mode
=
"
r
"
,
encoding
=
"
utf-8
"
)
as
f
:
with
open
(
notebook_file_path
,
mode
=
"
r
"
,
encoding
=
"
utf-8
"
)
as
f
:
nb
=
nbformat
.
read
(
f
,
as_version
=
4
)
nb
=
nbformat
.
read
(
f
,
as_version
=
4
)
...
@@ -161,23 +162,8 @@ for notebook_file_path in args.notebooks:
...
@@ -161,23 +162,8 @@ for notebook_file_path in args.notebooks:
if
"
CI_MERGE_REQUEST_SOURCE_PROJECT_URL
"
in
os
.
environ
:
if
"
CI_MERGE_REQUEST_SOURCE_PROJECT_URL
"
in
os
.
environ
:
repo
=
os
.
environ
[
"
CI_MERGE_REQUEST_SOURCE_PROJECT_URL
"
]
repo
=
os
.
environ
[
"
CI_MERGE_REQUEST_SOURCE_PROJECT_URL
"
]
branch
=
os
.
environ
[
"
CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
"
]
branch
=
os
.
environ
[
"
CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
"
]
# Insert Jupyter header with notebook source and binderhub link
binder_link
=
f
"
https://mybinder.org/v2/gh/bilke/binder-ogs-requirements/master?urlpath=git-pull%3Frepo=
{
repo
}
%26urlpath=lab/tree/ogs/
{
notebook_file_path_relative
}
%26branch=
{
branch
}
"
# Modify metadata
text
=
f
"""
<div class=
"
note
"
>
<p style=
"
margin-top: 0; margin-bottom: 0;
"
>
<img style=
"
margin-top: 0; margin-bottom: 0; height: 2em;
"
class=
"
inline-block mr-2 no-fancybox
"
src=
"
https://upload.wikimedia.org/wikipedia/commons/3/38/Jupyter_logo.svg
"
alt=
""
>
This page is based on a Jupyter notebook.
<a href=
"
{
repo
}
/-/blob/
{
branch
}
/
{
notebook_file_path_relative
}
"
><img src=
"
https://img.shields.io/static/v1?label=Source:&message=
{
notebook_filename
}
&color=brightgreen
"
class=
"
no-fancybox
"
style=
"
display: inline; margin-top: 0; margin-bottom: 0; margin-left: 1em;
"
/></a>
<a href=
"
{
binder_link
}
"
>
<img class=
"
no-fancybox
"
style=
"
display: inline; margin-top: 0; margin-bottom: 0; margin-left: 1em;
"
src=
"
https://img.shields.io/static/v1?label=&message=Launch notebook&color=5c5c5c&logo=data:image/png;base64,iVBORw0KGgoAAAAN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ell_type
==
"
raw
"
:
if
meta_cell
.
cell_type
==
"
raw
"
:
if
jupytext
:
if
jupytext
:
...
@@ -186,6 +172,32 @@ for notebook_file_path in args.notebooks:
...
@@ -186,6 +172,32 @@ for notebook_file_path in args.notebooks:
)
)
else
:
else
:
meta_cell
.
source
=
f
"
notebook = true
\n
{
meta_cell
.
source
}
"
meta_cell
.
source
=
f
"
notebook = true
\n
{
meta_cell
.
source
}
"
# Insert Jupyter header with notebook source and binderhub link
binder_link
=
f
"
https://mybinder.org/v2/gh/bilke/binder-ogs-requirements/master?urlpath=git-pull%3Frepo=
{
repo
}
%26urlpath=lab/tree/ogs/
{
notebook_file_path_relative
}
%26branch=
{
branch
}
"
text
=
f
"""
<div class=
"
note
"
>
<p style=
"
margin-top: 0; margin-bottom: 0;
"
>
<img style=
"
margin-top: 0; margin-bottom: 0; height: 2em;
"
class=
"
inline-block mr-2 no-fancybox
"
src=
"
https://upload.wikimedia.org/wikipedia/commons/3/38/Jupyter_logo.svg
"
alt=
""
>
This page is based on a Jupyter notebook.
"""
if
jupytext
:
download_file_name
=
(
Path
(
convert_notebook_file
)
.
rename
(
Path
(
convert_notebook_file
).
with_suffix
(
"
.ipynb
"
))
.
name
)
text
+=
f
"""
<a href=
"
./
{
download_file_name
}
"
download=
"
{
download_file_name
}
"
><img class=
"
no-fancybox
"
style=
"
display: inline; margin-top: 0; margin-bottom: 0; margin-left: 1em;
"
src=
"
https://img.shields.io/static/v1?label=Download:&message=
{
download_file_name
}
&color=blue
"
/></a>
"""
text
+=
f
"""
<a href=
"
{
repo
}
/-/blob/
{
branch
}
/
{
notebook_file_path_relative
}
"
><img src=
"
https://img.shields.io/static/v1?label=Source:&message=
{
notebook_filename
}
&color=brightgreen
"
class=
"
no-fancybox
"
style=
"
display: inline; margin-top: 0; margin-bottom: 0; margin-left: 1em;
"
/></a>
<a href=
"
{
binder_link
}
"
>
<img class=
"
no-fancybox
"
style=
"
display: inline; margin-top: 0; margin-bottom: 0; margin-left: 1em;
"
src=
"
https://img.shields.io/static/v1?label=&message=Launch notebook&color=5c5c5c&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH4gsEADkvyr8GjAAABQZJREFUSMeVlnlsVFUUh7/7ZukwpQxdoK2yGGgqYFKMQkyDUVBZJECQEERZVLQEa4iKiggiFjfqbkADhVSgEVkETVSiJBATsEIRja1RoCwuU5gC7Qww03Zm3rzrH/dOfJSZUm4y6Xt9957vnnN/55wruI7RVjMNQAA3AiX6bxw4BTQAQQDvnF1pbYjrAAEUAmXADGAQ0AOQwCWgHqgGdgCRdNBrAm2wW4A1wN2ACZwG/gbcQBFwg/Z2I/AS0JoKanQzmoXAamA0cBx4EhgDTAYmAvcArwNhYD6wHHDbNts9D20LlgMrgWPAXKAO/j8rPc8A5uiNAUwH9tjnddfDAn1mFkJWyoRR58hsv8KIfraAz/QvC3golf2UwEBZBYGyCoJfj/LFz/ceDxRJ09Hccbz/6dDu0ozg7lICZRVXrNFQEyWaDmAkkNslMAnSE59x9IrsMVt8awBP4rI3P9acs83hC3+BkFMAd2eoHn8BrdpG77RA2+IiYDPwHnAbEAOkMGQMcAKTdNheBXqmgDoBhw6xda2Q9tGHPhE4hRTlrrxQGRB29IqE3IUtTyDFu9rQC8AiwAiUVdgFNhTIA85oT68G2nb5ODABJf25niL/emfexX1AA0IWeIr8xWbY+yKwBJVzC4FSm71MlFIdwH505UnnYT5KWRawCvgp0eYBCKEqSBwpFuVMqp2a5Q1WO6TcakiZ55DWwyVVKxDC8gLPA1OAJh32q8qcHTgEKEbl2ncAua99lPy2FdgskH2FlFXNI8IVewcO8P+WUyjr8vqPfmvt+plhmVltIJeilLoK+CWVopy250LAgyrELcl/9nB/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+=
f
"""
</p></div>
"""
nb
[
"
cells
"
].
insert
(
1
,
nbformat
.
v4
.
new_markdown_cell
(
text
))
nb
[
"
cells
"
].
insert
(
1
,
nbformat
.
v4
.
new_markdown_cell
(
text
))
nbformat
.
write
(
nb
,
f
)
nbformat
.
write
(
nb
,
f
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment