Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
nanowire-toymodel-conductance
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
flyzenr
nanowire-toymodel-conductance
Commits
c2491021
Commit
c2491021
authored
5 years ago
by
Bas Nijholt
Browse files
Options
Downloads
Patches
Plain Diff
add ipynb_filter
parent
119d6599
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitattributes
+1
-0
1 addition, 0 deletions
.gitattributes
ipynb_filter.py
+34
-0
34 additions, 0 deletions
ipynb_filter.py
with
35 additions
and
0 deletions
.gitattributes
0 → 100644
+
1
−
0
View file @
c2491021
*.ipynb filter=ipynb_filter
This diff is collapsed.
Click to expand it.
ipynb_filter.py
0 → 100644
+
34
−
0
View file @
c2491021
#!/usr/bin/env python3
# `ipynb_filter.py`:
# This is a git filters that strips out the outputs and
# meta data of a Jupyer notebook using `nbconvert`.
# Execute the following line in order to activate this filter:
# python ipynb_filter.py
#
# The following line should be in `.gitattributes`:
# *.ipynb filter=ipynb_filter
#
# from github.com/basnijholt/ipynb_git_filters
from
nbconvert.preprocessors
import
Preprocessor
class
RemoveMetadata
(
Preprocessor
):
def
preprocess
(
self
,
nb
,
resources
):
nb
.
metadata
=
{
"
language_info
"
:
{
"
name
"
:
"
python
"
,
"
pygments_lexer
"
:
"
ipython3
"
}}
return
nb
,
resources
if
__name__
==
'
__main__
'
:
# The filter is getting activated
import
os
git_cmd
=
'
git config filter.ipynb_filter.clean
"
jupyter nbconvert --to notebook --config ipynb_filter.py --stdin --stdout
"'
os
.
system
(
git_cmd
)
else
:
# This script is used as config
c
.
Exporter
.
preprocessors
=
[
RemoveMetadata
]
c
.
ClearOutputPreprocessor
.
enabled
=
True
c
.
ClearOutputPreprocessor
.
remove_metadata_fields
=
[
"
deletable
"
,
"
editable
"
,
"
collapsed
"
,
"
scrolled
"
]
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