feat(sdk): bring sdk/python/ to parity, fix JS SDK bugs #61
Merged
wasabi opened 5 days ago

Summary

Adds documentation, fixes configuration bugs, and aligns both SDKs with the actual database schema.

Python SDK Changes

Documentation

  • sdk/python/README.md — install, usage, error handling, method group reference, and examples.

Bug Fixes

  • sdk/python/pyproject.tomlpackages.find was where=[".."] include=["services*", "sdk*"] which would bundle the entire services/ directory into the pip package. Fixed to where=["."] include=["kokonut*"]. Removed unnecessary psycopg2-binary hard dependency (SDK is a REST client, never uses psycopg2). Added license and [project.urls].
  • sdk/python/kokonut/client.py — renamed PermissionErrorForbiddenError to avoid shadowing Python's built-in PermissionError (which breaks except PermissionError patterns).
  • sdk/python/kokonut/__init__.py — exported error classes (KokonutError, AuthenticationError, NotFoundError, ForbiddenError, ValidationError) so users can from kokonut import NotFoundError directly.

Quality Improvements

  • sdk/python/kokonut/py.typed — PEP 561 marker for type-checking support.
  • sdk/python/kokonut/types.py — added format, entity_type, entity_ids fields to ExportLog dataclass.
  • sdk/python/kokonut/methods.py — enriched ExportMethods.create_export with format, entity_type, entity_ids params to match JS SDK.

JS SDK Bug Fixes (found during Python comparison)

  • sdk/javascript/src/methods.tslistByEntity was filtering on entity_type/entity_id, but the attestation_record table uses subject_type/subject_id (confirmed in 006_web3.sql:178-179). Fixed to use correct column names.
  • sdk/javascript/src/methods.tslistAnomalies was filtering on anomaly_flag = true, but sensor_reading has no anomaly_flag column. The correct filter is quality = "suspect" (confirmed in 005_environmental.sql:171). Fixed.

Verification

  • Python SDK: from kokonut import KokonutClient, NotFoundError, ForbiddenError works
  • pyproject.toml: pip install -e . installs only the kokonut package, not services/
  • JS SDK: listByEntity and listAnomalies now use correct database column names
  • No whitespace errors
Commits were merged into target branch
  • feat(sdk): bring sdk/python/ to parity, fix JS SDK bugs
    Python SDK:
    - Add sdk/python/README.md with install, usage, error handling, method
      groups, and examples reference.
    - Fix pyproject.toml: packages.find was where=['..'] include=['services*',
      'sdk*'] which would bundle the entire services/ directory. Fixed to
      where=['.'] include=['kokonut*']. Removed unnecessary psycopg2-binary
      hard dependency. Added license and project.urls.
    - Rename PermissionError → ForbiddenError to avoid shadowing Python
      built-in (breaks except PermissionError patterns).
    - Export error classes from __init__.py (KokonutError, AuthenticationError,
      NotFoundError, ForbiddenError, ValidationError).
    - Add py.typed marker for PEP 561 type-checking support.
    - Enrich ExportMethods.create_export with format, entity_type, entity_ids
      params to match JS SDK. Add format, entity_type, entity_ids fields to
      ExportLog dataclass.
    
    JS SDK bug fixes:
    - Fix listByEntity: entity_type/entity_id → subject_type/subject_id
      (attestation_record table uses subject_type/subject_id per
      006_web3.sql:178-179).
    - Fix listAnomalies: anomaly_flag=true → quality={_eq:'suspect'}
      (sensor_reading table has no anomaly_flag column, only quality column
      per 005_environmental.sql:171).
    5 days ago
  • feat(sdk): bring sdk/python/ to parity, fix JS SDK bugs
    Python SDK:
    - Add sdk/python/README.md with install, usage, error handling, method
      groups, and examples reference.
    - Fix pyproject.toml: packages.find was where=['..'] include=['services*',
      'sdk*'] which would bundle the entire services/ directory. Fixed to
      where=['.'] include=['kokonut*']. Removed unnecessary psycopg2-binary
      hard dependency. Added license and project.urls.
    - Rename PermissionError → ForbiddenError to avoid shadowing Python
      built-in (breaks except PermissionError patterns).
    - Export error classes from __init__.py (KokonutError, AuthenticationError,
      NotFoundError, ForbiddenError, ValidationError).
    - Add py.typed marker for PEP 561 type-checking support.
    - Enrich ExportMethods.create_export with format, entity_type, entity_ids
      params to match JS SDK. Add format, entity_type, entity_ids fields to
      ExportLog dataclass.
    
    JS SDK bug fixes:
    - Fix listByEntity: entity_type/entity_id → subject_type/subject_id
      (attestation_record table uses subject_type/subject_id per
      006_web3.sql:178-179).
    - Fix listAnomalies: anomaly_flag=true → quality={_eq:'suspect'}
      (sensor_reading table has no anomaly_flag column, only quality column
      per 005_environmental.sql:171).
    5 days ago
  • wasabi merged 5 days ago
1/1
Submitter wasabi
Target main
Source feat/sdk-python-parity
Jobs
Merge Strategy
Create Merge Commit
Watchers (1)
Reference
pull request KI-61
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover