Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Flatland
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
pranjal_dhole
Flatland
Commits
77b43286
Commit
77b43286
authored
5 years ago
by
u214892
Browse files
Options
Downloads
Patches
Plain Diff
#97 tox-conda #94 use miniconda instead of anaconda
parent
7160aec7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
notebooks/__init__.py
+0
-0
0 additions, 0 deletions
notebooks/__init__.py
notebooks/run_all_notebooks.py
+54
-0
54 additions, 0 deletions
notebooks/run_all_notebooks.py
with
54 additions
and
0 deletions
notebooks/__init__.py
0 → 100644
+
0
−
0
View file @
77b43286
This diff is collapsed.
Click to expand it.
notebooks/run_all_notebooks.py
0 → 100644
+
54
−
0
View file @
77b43286
import
shlex
import
sys
from
subprocess
import
Popen
,
PIPE
import
importlib_resources
import
pkg_resources
from
importlib_resources
import
path
from
ipython_genutils.py3compat
import
string_types
,
bytes_to_str
# taken from https://github.com/jupyter/nbconvert/blob/master/nbconvert/tests/base.py
def
run_python
(
parameters
,
ignore_return_code
=
False
,
stdin
=
None
):
"""
Run python as a shell command, listening for both Errors and
non-zero return codes. Returns the tuple (stdout, stderr) of
output produced during the nbconvert run.
Parameters
----------
parameters : str, list(str)
List of parameters to pass to IPython.
ignore_return_code : optional bool (default False)
Throw an OSError if the return code
"""
cmd
=
[
sys
.
executable
]
if
sys
.
platform
==
'
win32
'
:
if
isinstance
(
parameters
,
string_types
):
cmd
=
'
'
.
join
(
cmd
)
+
'
'
+
parameters
else
:
cmd
=
'
'
.
join
(
cmd
+
parameters
)
else
:
if
isinstance
(
parameters
,
string_types
):
parameters
=
shlex
.
split
(
parameters
)
cmd
+=
parameters
p
=
Popen
(
cmd
,
stdout
=
PIPE
,
stderr
=
PIPE
,
stdin
=
PIPE
)
stdout
,
stderr
=
p
.
communicate
(
input
=
stdin
)
if
not
(
p
.
returncode
==
0
or
ignore_return_code
):
raise
OSError
(
bytes_to_str
(
stderr
))
return
stdout
.
decode
(
'
utf8
'
,
'
replace
'
),
stderr
.
decode
(
'
utf8
'
,
'
replace
'
)
for
entry
in
[
entry
for
entry
in
importlib_resources
.
contents
(
'
notebooks
'
)
if
not
pkg_resources
.
resource_isdir
(
'
notebooks
'
,
entry
)
and
entry
.
endswith
(
"
.ipynb
"
)
]:
print
(
"
*****************************************************************
"
)
print
(
"
Converting and running {}
"
.
format
(
entry
))
print
(
"
*****************************************************************
"
)
with
path
(
'
notebooks
'
,
entry
)
as
file_in
:
out
,
err
=
run_python
(
"
-m jupyter nbconvert --execute --to notebook --inplace
"
+
str
(
file_in
))
sys
.
stderr
.
write
(
err
)
sys
.
stderr
.
flush
()
sys
.
stdout
.
write
(
out
)
sys
.
stdout
.
flush
()
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