Skip to content

Commit

Permalink
Add taxonomy qna.yaml parsing API
Browse files Browse the repository at this point in the history
The parse method will yamllint and jsonschema validate a qna.yaml file.

Signed-off-by: BJ Hargrave <hargrave@us.ibm.com>
  • Loading branch information
bjhargrave committed Jun 28, 2024
1 parent 72984c1 commit 2063382
Show file tree
Hide file tree
Showing 16 changed files with 790 additions and 20 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ updates:
directory: "/.github/workflows"
schedule:
interval: "daily"

# Maintain dependencies for Python code
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
27 changes: 26 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dynamic = ["dependencies", "optional-dependencies", "version"]
dependencies = [
"typing_extensions",
"jsonschema>=4.22.0",
"PyYAML>=6.0.0",
# The below library should NOT be imported into any python files
# We only use the command via subprocess
"yamllint>=1.35.1",
]
dynamic = ["version"]

[project.urls]
homepage = "https://instructlab.ai"
Expand All @@ -40,6 +48,7 @@ exclude = ["^src/instructlab/schema/_version\\.py$"]
target-version = "py310"
src = ["src", "tests"]
extend-exclude = ["src/instructlab/schema/_version.py"]
line-length = 180

[tool.ruff.lint]
select = [
Expand All @@ -52,12 +61,28 @@ select = [
"SIM", # flake8-simplify
"TID", # flake8-tidy-imports
]
ignore = [
"B019", # cached-instance-method
]

[tool.ruff.lint.flake8-tidy-imports.banned-api]
"yamllint".msg = "yamllint is for use as a command via subprocess."

[tool.pylint.main]
py-version = "3.10"
source-roots = ["src", "tests"]
ignore = ["_version.py"]

[tool.pylint.design]
max-branches = 30
max-line-length = 180
max-locals = 30
max-statements = 80
min-public-methods = 1

[tool.pylint.format]
max-args = 10

[tool.pylint."messages control"]
disable = [
"missing-class-docstring",
Expand Down
15 changes: 12 additions & 3 deletions src/instructlab/schema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@
except ImportError: # python<3.11
from importlib.abc import Traversable

__all__ = ["schema_versions"]
__all__ = ["schema_base", "schema_versions"]


def schema_base() -> Traversable:
"""Return the schema base.
Returns:
Traversable: The base for the schema versions.
"""
base = resources.files(__package__)
return base


def schema_versions() -> list[Traversable]:
Expand All @@ -19,9 +29,8 @@ def schema_versions() -> list[Traversable]:
Returns:
list[Traversable]: A sorted list of schema versions.
"""
schema_base = resources.files(__package__)
versions = sorted(
(v for v in schema_base.iterdir() if v.name[0] == "v" and v.name[1:].isdigit()),
(v for v in schema_base().iterdir() if v.name[0] == "v" and v.name[1:].isdigit()),
key=lambda k: int(k.name[1:]),
)
return versions
Loading

0 comments on commit 2063382

Please sign in to comment.