Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ PYTHON ?= $(PY_ENV_DIR)/bin/python
endif
PY_ENV_STAMP := $(PY_ENV_DIR)/.stamp
INSTALL_STAMP := $(PY_ENV_DIR)/.install-stamp
LOCAL_DIST_DIR := dist-install-local

ifneq ($(filter install-local uninstall-local,$(MAKECMDGOALS)),)
ifeq ($(origin PYTHON),file)
Expand All @@ -38,6 +39,9 @@ help:
# Create/update the virtual environment and install dev/test dependencies
py-env: $(PY_ENV_STAMP)

$(PY_ENV_DIR)/bin/python:
$(PYTHON_BOOTSTRAP) -m venv $(PY_ENV_DIR)

$(PY_ENV_STAMP): gts/pyproject.toml .gts-spec/tests/requirements.txt Makefile
@echo "Creating/updating Python virtual environment in $(PY_ENV_DIR)..."
$(PYTHON_BOOTSTRAP) -m venv $(PY_ENV_DIR)
Expand All @@ -60,8 +64,11 @@ build: py-env
$(PYTHON) -m build --outdir dist ./gts

# Install the locally built wheel, equivalent to installing the published gts package
install-local: build
$(PYTHON) -m pip install --force-reinstall dist/gts-*.whl
install-local: $(if $(filter $(PY_ENV_DIR)/bin/python,$(PYTHON)),$(PY_ENV_DIR)/bin/python)
@rm -rf $(LOCAL_DIST_DIR)
$(PYTHON) -m pip install --upgrade build
$(PYTHON) -m build --outdir $(LOCAL_DIST_DIR) ./gts
$(PYTHON) -m pip install --force-reinstall $(LOCAL_DIST_DIR)/gts-*.whl

# Uninstall gts from the selected interpreter
uninstall-local:
Expand All @@ -70,7 +77,7 @@ uninstall-local:

# Remove venv and build artifacts
clean:
rm -rf $(PY_ENV_DIR) dist/ gts/dist/ gts/*.egg-info
rm -rf $(PY_ENV_DIR) dist/ $(LOCAL_DIST_DIR) gts/dist/ gts/*.egg-info

# -------- Code quality --------

Expand Down
16 changes: 16 additions & 0 deletions gts/src/gts/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ def build_parser() -> argparse.ArgumentParser:
)
s.add_argument("--gts-id", required=True, help="GTS ID of the object")

s = sub.add_parser(
"validate-type-schema",
help="Validate a type schema against its base type schema (OP#12 schema-vs-schema)",
)
s.add_argument("--gts-id", required=True, help="GTS ID of the type schema")

s = sub.add_parser(
"validate-entity",
help="Validate an entity (instance or schema) by GTS ID",
)
s.add_argument("--gts-id", required=True, help="GTS ID of the entity")

s = sub.add_parser(
"resolve-relationships", help="Resolve relationships for an entity"
)
Expand Down Expand Up @@ -144,6 +156,10 @@ def main(argv: list[str] | None = None) -> None:
out = ops.uuid(args.gts_id).to_dict()
elif args.op == "validate-instance":
out = ops.validate_instance(args.gts_id).to_dict()
elif args.op == "validate-type-schema":
out = ops.validate_schema(args.gts_id).to_dict()
elif args.op == "validate-entity":
out = ops.validate_entity(args.gts_id).to_dict()
elif args.op == "resolve-relationships":
out = ops.schema_graph(args.gts_id).to_dict()
elif args.op == "compatibility":
Expand Down
10 changes: 10 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
"--gts-id",
"gts.vendor.package.namespace.type.v1~vendor.package.namespace.item.v1",
],
[
"validate-type-schema",
"--gts-id",
"gts.vendor.package.namespace.type.v1~",
],
[
"validate-entity",
"--gts-id",
"gts.vendor.package.namespace.type.v1~",
],
["resolve-relationships", "--gts-id", "gts.vendor.package.namespace.type.v1~"],
[
"compatibility",
Expand Down
Loading