Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit d5a1752

Browse files
authored
Merge pull request #33 from bjhargrave/taxonomy-reading
Taxonomy reading API
2 parents fb19e0f + b903539 commit d5a1752

File tree

25 files changed

+1205
-114
lines changed

25 files changed

+1205
-114
lines changed

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,10 @@ updates:
1313
directory: "/.github/workflows"
1414
schedule:
1515
interval: "daily"
16+
17+
# Maintain dependencies for Python code
18+
- package-ecosystem: "pip"
19+
directory: "/"
20+
versioning-strategy: "increase-if-necessary"
21+
schedule:
22+
interval: "daily"

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
tox -e jsonschema
4949
- name: "ruff"
5050
commands: |
51-
tox -e ruff -- check
51+
tox -e ruffcheck
5252
- name: "pylint"
5353
commands: |
5454
echo "::add-matcher::.github/workflows/matchers/pylint.json"

.github/workflows/test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ jobs:
4141
strategy:
4242
matrix:
4343
python:
44-
- "3.9"
4544
- "3.10"
4645
- "3.11"
4746
- "3.12"

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Taxonomy Schema
22

3-
This Python package defines the JSON schema for the InstructLab [Taxonomy](https://github.com/instructlab/taxonomy) YAML.
3+
This Python package defines the JSON schema and a parser for the InstructLab [Taxonomy](https://github.com/instructlab/taxonomy) YAML.
44

5-
Consumers of this schema can `pip install instructlab-schema`, and access the schema files using `importlib.resources` on the `instructlab.schema` package.
5+
Consumers of this schema can `pip install instructlab-schema`, and use the `instructlab.schema.taxonomy.TaxonomyParser` class to parse and validate `qna.yaml` taxonomy files.
6+
Schema files can be directly accessed using the `instructlab.schema.schema_base()` method to get access the base of the schema resources.

pyproject.toml

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
[build-system]
4-
requires = ["setuptools>=64", "setuptools_scm>=8"]
4+
requires = ["setuptools>=70.1.0", "setuptools_scm>=8"]
55
build-backend = "setuptools.build_meta"
66

77
[project]
@@ -10,19 +10,26 @@ authors = [{ name = "InstructLab", email = "[email protected]" }]
1010
description = "InstructLab Taxonomy Schema"
1111
readme = "README.md"
1212
license = { text = "Apache-2.0" }
13-
requires-python = ">=3.9"
13+
requires-python = ">=3.10"
1414
classifiers = [
1515
"Development Status :: 4 - Beta",
1616
"License :: OSI Approved :: Apache Software License",
1717
"Operating System :: OS Independent",
1818
"Topic :: Scientific/Engineering :: Artificial Intelligence",
1919
"Programming Language :: Python :: 3",
20-
"Programming Language :: Python :: 3.9",
2120
"Programming Language :: Python :: 3.10",
2221
"Programming Language :: Python :: 3.11",
2322
"Programming Language :: Python :: 3.12",
2423
]
25-
dynamic = ["dependencies", "optional-dependencies", "version"]
24+
dependencies = [
25+
"typing_extensions",
26+
"jsonschema>=4.22.0",
27+
"PyYAML>=6.0.0",
28+
# The below library should NOT be imported into any python files
29+
# We only use the command via subprocess
30+
"yamllint>=1.35.1",
31+
]
32+
dynamic = ["version"]
2633

2734
[project.urls]
2835
homepage = "https://instructlab.ai"
@@ -34,13 +41,14 @@ version_file = "src/instructlab/schema/_version.py"
3441
local_scheme = "no-local-version" # do not include +gREV local version, required for Test PyPI upload
3542

3643
[tool.mypy]
37-
python_version = "3.9"
44+
python_version = "3.10"
3845
exclude = ["^src/instructlab/schema/_version\\.py$"]
3946

4047
[tool.ruff]
41-
target-version = "py39"
48+
target-version = "py310"
4249
src = ["src", "tests"]
4350
extend-exclude = ["src/instructlab/schema/_version.py"]
51+
line-length = 180
4452

4553
[tool.ruff.lint]
4654
select = [
@@ -54,11 +62,23 @@ select = [
5462
"TID", # flake8-tidy-imports
5563
]
5664

65+
[tool.ruff.lint.flake8-tidy-imports.banned-api]
66+
"yamllint".msg = "yamllint is for use as a command via subprocess."
67+
5768
[tool.pylint.main]
58-
py-version = "3.9"
69+
py-version = "3.10"
5970
source-roots = ["src", "tests"]
6071
ignore = ["_version.py"]
6172

73+
[tool.pylint.design]
74+
max-branches = 20
75+
max-line-length = 180
76+
max-locals = 20
77+
min-public-methods = 1
78+
79+
[tool.pylint.format]
80+
max-args = 8
81+
6282
[tool.pylint."messages control"]
6383
disable = [
6484
"missing-class-docstring",

scripts/ruff.sh

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/instructlab/schema/__init__.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
13
"""InstructLab Taxonomy Schema"""
24

35
# Standard
4-
from importlib import resources
6+
import importlib.resources
7+
from importlib.abc import Traversable
8+
9+
__all__ = ["schema_base", "schema_versions"]
10+
511

6-
try:
7-
from importlib.resources.abc import Traversable # type: ignore[import-not-found]
8-
except ImportError: # python>=3.9,<3.11
9-
from importlib.abc import Traversable
12+
def schema_base() -> Traversable:
13+
"""Return the schema base.
1014
11-
__all__ = ["schema_versions"]
15+
Returns:
16+
Traversable: The base for the schema versions.
17+
"""
18+
base = importlib.resources.files(__name__)
19+
return base
1220

1321

1422
def schema_versions() -> list[Traversable]:
@@ -17,9 +25,8 @@ def schema_versions() -> list[Traversable]:
1725
Returns:
1826
list[Traversable]: A sorted list of schema versions.
1927
"""
20-
schema_base = resources.files(__package__)
2128
versions = sorted(
22-
(v for v in schema_base.iterdir() if v.name[0] == "v" and v.name[1:].isdigit()),
29+
(v for v in schema_base().iterdir() if v.name[0] == "v" and v.name[1:].isdigit()),
2330
key=lambda k: int(k.name[1:]),
2431
)
2532
return versions

0 commit comments

Comments
 (0)