Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
added notebook formatter in workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Mar 4, 2024
1 parent 6a24b5c commit 6a52501
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/fixNotebooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Tests

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
fix-notebooks:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@main
with:
ref: main
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@main
with:
python-version: '3.10'

- id: fixNotebooks
name: Fix notebook output
uses: GabrielBB/xvfb-action@v1
with:
working-directory: ${{ github.workspace }}
run: |
python -c "from biosimulator_processes.utils import fix_notebooks_execution_count; fix_notebooks_execution_count(); exit();"
8 changes: 8 additions & 0 deletions biosimulator_processes/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Dict
import os
from basico import biomodels, load_model_from_string
from process_bigraph import Composite, pf
import nbformat
Expand Down Expand Up @@ -241,3 +242,10 @@ def fix_execution_count(notebook_path):

with open(notebook_path, 'w', encoding='utf-8') as f:
nbformat.write(nb, f)


def fix_notebooks_execution_count():
for root, _, files in os.walk('../notebooks'):
for _file in files:
notebook_path = os.path.join(root, _file)
fix_execution_count(notebook_path)

0 comments on commit 6a52501

Please sign in to comment.