Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SCHEMA] Reorganize schema code into a package #892

Merged
merged 38 commits into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b5e745e
Start reorganizing.
tsalo Oct 5, 2021
2bf9b6a
Merge branch 'master' into schema-package
tsalo Oct 5, 2021
2cbcffc
Clean up docstrings.
tsalo Oct 5, 2021
13044ba
Change license to MIT.
tsalo Oct 11, 2021
73e89c5
Fix spelling in versioneer files.
tsalo Oct 11, 2021
4b59f93
Install schemacode in config file.
tsalo Oct 11, 2021
5df0354
Update config.yml
tsalo Oct 11, 2021
5383948
Fix path to schema.
tsalo Oct 11, 2021
f2492f8
Log.
tsalo Oct 11, 2021
4d594f4
Why isn't CircleCI working?
tsalo Oct 11, 2021
2c7db1a
Make loading function more restrictive.
tsalo Oct 11, 2021
a3e7dfe
Move rendering functions into a new module.
tsalo Oct 11, 2021
1a7e713
RF: Use setup.cfg over info.py
effigies Dec 15, 2021
74b5e31
ENH: Link schema code into package
effigies Dec 15, 2021
af516d8
RF: Use packaged schema
effigies Dec 15, 2021
7d9daec
Merge remote-tracking branch 'upstream/master' into schema-package
effigies Dec 15, 2021
fadc12c
MNT: Require schemacode package to build docs
effigies Dec 15, 2021
61b13fe
Fix locations of functions.
tsalo Dec 15, 2021
43c7a37
Add a couple of tests.
tsalo Dec 15, 2021
3b54a61
Draft a couple more tests.
tsalo Dec 15, 2021
376fbcb
Draft Action for schemacode CI.
tsalo Dec 16, 2021
1332c9e
Fix installation.
tsalo Dec 16, 2021
7858106
Update schemacode_ci.yml
tsalo Dec 16, 2021
2e48e7d
Add badge.
tsalo Dec 16, 2021
963ad61
Add schema-related files to the CODEOWNERS file.
tsalo Dec 16, 2021
31bcd19
Run versioneer 0.21 instead of 0.18 and run black.
tsalo Dec 16, 2021
f766804
Add numpy back in as a general dependency.
tsalo Dec 16, 2021
181df00
Apply suggestions from code review
tsalo Dec 18, 2021
2557616
Add path restriction to pull requests too.
tsalo Dec 18, 2021
e19f103
Add license badge.
tsalo Dec 18, 2021
cc5ed8e
Try out linting job.
tsalo Dec 18, 2021
a71a323
Fix name.
tsalo Dec 18, 2021
ce53a66
Don't use the flake8 action.
tsalo Dec 18, 2021
712a1f6
Change working directory to use config.
tsalo Dec 18, 2021
cf9b6b7
Run black on versioneer files.
tsalo Dec 18, 2021
e4d3f08
Fix linting issue.
tsalo Dec 18, 2021
adeeeed
Apply @effigies' suggestions
tsalo Jan 5, 2022
97794d5
Remove unused imports.
tsalo Jan 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
command: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install ~/project/tools/schemacode/
- run:
name: generate docs
command: mkdocs build --clean --strict --verbose
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.png -text
*.jpg -text
*.webm -text
tools/schemacode/schemacode/_version.py export-subst
94 changes: 94 additions & 0 deletions .github/workflows/schemacode_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: "schemacode_ci"

on:
push:
branches:
tsalo marked this conversation as resolved.
Show resolved Hide resolved
- "master"
paths:
- "tools/schemacode/**"
- "src/schema/**"
pull_request:
branches:
- "*"
paths:
- "tools/schemacode/**"
- "src/schema/**"

jobs:
check_skip:
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.result_step.outputs.ci-skip }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- id: result_step
uses: mstachniuk/ci-skip@master
with:
commit-filter: "[skip ci];[ci skip];[skip github]"
commit-filter-separator: ";"

run_tests:
needs: check_skip
if: ${{ needs.check_skip.outputs.skip == 'false' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
name: ${{ matrix.os }} with Python ${{ matrix.python-version }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v2

- name: "Set up Python"
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: "Display Python version"
shell: bash {0}
run: python -c "import sys; print(sys.version)"

- name: "Install the schemacode package"
shell: bash {0}
run: |
python -m pip install --progress-bar off --upgrade pip setuptools wheel
python -m pip install -e ./tools/schemacode[tests]

- name: "Run tests"
shell: bash {0}
run: |
python -m pytest --pyargs schemacode --cov=schemacode ./tools/schemacode/

- name: "Upload coverage to CodeCov"
uses: codecov/codecov-action@v1
if: success()

flake8-lint:
runs-on: ubuntu-latest
name: Lint schemacode
steps:
- name: Check out source repository
uses: actions/checkout@v2

- name: Set up Python environment
uses: actions/setup-python@v2
with:
python-version: "3.7"

- name: "Install the schemacode package"
shell: bash {0}
run: |
python -m pip install --progress-bar off --upgrade pip setuptools wheel
python -m pip install -e ./tools/schemacode[tests]

- name: "Run flake8"
working-directory: ./tools/schemacode/
shell: bash {0}
run: |
flake8 .
4 changes: 4 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@
/src/05-derivatives/05-functional-derivatives.md @effigies
/src/05-derivatives/06-diffusion-derivatives.md @francopestilli @oesteban @Lestropie
/src/99-appendices/06-meg-file-formats.md @monkeyman192

# The schema
/src/schema/ @tsalo
/tools/schemacode/ @tsalo
4 changes: 1 addition & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ pymdown-extensions>=7.0.0
mkdocs-branchcustomization-plugin~=0.1.3
mkdocs-macros-plugin
numpy
pandas
PYYaml
tabulate
tools/schemacode/
17 changes: 9 additions & 8 deletions tools/mkdocs_macros_bids/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import os
import sys

from schemacode import render, schema, utils

code_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.append(code_path)

from examplecode import example
from schemacode import schema, utils


def make_filename_template(**kwargs):
Expand All @@ -28,7 +29,7 @@ def make_filename_template(**kwargs):
"""
schemapath = utils.get_schema_path()
schema_obj = schema.load_schema(schemapath)
codeblock = schema.make_filename_template(schema_obj, **kwargs)
codeblock = render.make_filename_template(schema_obj, **kwargs)
return codeblock


Expand All @@ -50,7 +51,7 @@ def make_entity_table(**kwargs):
"""
schemapath = utils.get_schema_path()
schema_obj = schema.load_schema(schemapath)
table = schema.make_entity_table(schema_obj, **kwargs)
table = render.make_entity_table(schema_obj, **kwargs)
return table


Expand All @@ -66,7 +67,7 @@ def make_entity_definitions():
"""
schemapath = utils.get_schema_path()
schema_obj = schema.load_schema(schemapath)
text = schema.make_entity_definitions(schema_obj)
text = render.make_entity_definitions(schema_obj)
return text


Expand All @@ -81,7 +82,7 @@ def make_glossary():
"""
schemapath = utils.get_schema_path()
schema_obj = schema.load_schema(schemapath)
text = schema.make_glossary(schema_obj)
text = render.make_glossary(schema_obj)
return text


Expand All @@ -101,7 +102,7 @@ def make_suffix_table(suffixes):
"""
schemapath = utils.get_schema_path()
schema_obj = schema.load_schema(schemapath)
table = schema.make_suffix_table(schema_obj, suffixes)
table = render.make_suffix_table(schema_obj, suffixes)
return table


Expand All @@ -126,7 +127,7 @@ def make_metadata_table(field_info):
"""
schemapath = utils.get_schema_path()
schema_obj = schema.load_schema(schemapath)
table = schema.make_metadata_table(schema_obj, field_info)
table = render.make_metadata_table(schema_obj, field_info)
return table


Expand All @@ -151,7 +152,7 @@ def make_columns_table(column_info):
"""
schemapath = utils.get_schema_path()
schema_obj = schema.load_schema(schemapath)
table = schema.make_columns_table(schema_obj, column_info)
table = render.make_columns_table(schema_obj, column_info)
return table


Expand Down
2 changes: 2 additions & 0 deletions tools/schemacode/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include versioneer.py
include schemacode/_version.py
6 changes: 6 additions & 0 deletions tools/schemacode/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# schemacode

A Python library for working with the BIDS schema.

[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![codecov](https://codecov.io/gh/bids-standard/bids-specification/branch/master/graph/badge.svg)](https://codecov.io/gh/bids-standard/bids-specification)
7 changes: 0 additions & 7 deletions tools/schemacode/__init__.py

This file was deleted.

27 changes: 27 additions & 0 deletions tools/schemacode/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[build-system]
requires = ["setuptools", "wheel"]

[tool.black]
line-length = 99
target-version = ['py37']
include = '\.pyi?$'
exclude = '''
(
/(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.github
| \.hg
| \.pytest_cache
| _build
| build
| dist
)/
| versioneer.py
| schemacode/_version.py
)
'''

[tool.isort]
profile = "black"
multi_line_output = 3
12 changes: 12 additions & 0 deletions tools/schemacode/schemacode/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""A Python package for working with the BIDS schema."""
from . import render, schema, utils

__all__ = [
"render",
"schema",
"utils",
]

from . import _version

__version__ = _version.get_versions()["version"]
Loading