inputlayer-client-dev 0.1.0.dev913__tar.gz → 0.1.0.dev919__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- inputlayer_client_dev-0.1.0.dev919/LICENSE +203 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/PKG-INFO +13 -12
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/README.md +10 -10
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/pyproject.toml +2 -2
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/__init__.py +0 -4
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/migrations/__init__.py +0 -19
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/migrations/cli.py +26 -1
- inputlayer_client_dev-0.1.0.dev919/src/inputlayer/migrations/errors.py +27 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/migrations/executor.py +15 -6
- inputlayer_client_dev-0.1.0.dev919/src/inputlayer/migrations/loader.py +135 -0
- inputlayer_client_dev-0.1.0.dev919/src/inputlayer/migrations/recorder.py +83 -0
- inputlayer_client_dev-0.1.0.dev919/src/inputlayer/migrations/writer.py +51 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_cli.py +45 -3
- inputlayer_client_dev-0.1.0.dev919/tests/test_loader.py +167 -0
- inputlayer_client_dev-0.1.0.dev919/tests/test_migration_safety.py +167 -0
- inputlayer_client_dev-0.1.0.dev919/tests/test_writer.py +129 -0
- inputlayer_client_dev-0.1.0.dev913/src/inputlayer/migrations/loader.py +0 -90
- inputlayer_client_dev-0.1.0.dev913/src/inputlayer/migrations/recorder.py +0 -44
- inputlayer_client_dev-0.1.0.dev913/src/inputlayer/migrations/writer.py +0 -208
- inputlayer_client_dev-0.1.0.dev913/tests/test_loader.py +0 -232
- inputlayer_client_dev-0.1.0.dev913/tests/test_writer.py +0 -169
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/.gitignore +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/01_quickstart.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/02_social_network.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/03_rag_pipeline.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/04_ecommerce.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/05_rbac.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/06_realtime_dashboard.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/07_dataframe_etl.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/08_session_rules.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/09_access_control.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/10_migrations.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langchain/__init__.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langchain/_common.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langchain/ex01_retriever.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langchain/ex02_vector.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langchain/ex03_tool.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langchain/ex04_lcel_chain.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langchain/ex05_kg_building.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langchain/ex06_explainable_rag.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langchain/ex07_multihop.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langchain/ex08_memory.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langchain/ex09_access_control.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langchain/ex10_multi_agent.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langchain/ex11_anomaly.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langchain/ex12_hallucination.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langchain/ex13_guardrails.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langchain/ex14_graphrag.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langchain/ex15_caching.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langchain/ex16_recommendation.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langchain/ex17_lineage.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langchain/runner.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langgraph/__init__.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langgraph/_common.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langgraph/ex01_reasoning_loop.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langgraph/ex02_investigation.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langgraph/ex03_human_in_loop.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langgraph/ex04_branching_pipeline.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langgraph/ex05_self_correcting.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langgraph/ex06_collaborative_planning.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langgraph/ex07_event_correlation.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langgraph/ex08_tool_selection.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langgraph/ex09_streaming_aggregation.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langgraph/ex10_resumable_graph.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langgraph/ex11_memory.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langgraph/ex12_resumable_chat.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/examples/langgraph/runner.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/_ast.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/_naming.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/_protocol.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/_proxy.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/_sync.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/aggregations.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/auth.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/client.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/client_sync.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/compiler.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/connection.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/derived.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/exceptions.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/functions.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/index.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/integrations/__init__.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/integrations/langchain/__init__.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/integrations/langchain/params.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/integrations/langchain/retriever.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/integrations/langchain/tool.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/integrations/langchain/vector_store.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/integrations/langgraph/__init__.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/integrations/langgraph/_checkpoint_serde.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/integrations/langgraph/_checkpointer_mixin.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/integrations/langgraph/_memory_helpers.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/integrations/langgraph/_memory_mixin.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/integrations/langgraph/_utils.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/integrations/langgraph/checkpointer.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/integrations/langgraph/memory.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/integrations/langgraph/nodes.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/integrations/langgraph/router.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/integrations/langgraph/state.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/knowledge_graph.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/migrations/autodetector.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/migrations/operations.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/migrations/state.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/notifications.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/py.typed +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/relation.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/result.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/session.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/types.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/__init__.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/_mock_checkpoint_kg.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/_mock_memory_kg.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/conftest.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_aggregations.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_ast.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_autodetector.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_checkpointer_core.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_checkpointer_lifecycle.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_checkpointer_list.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_checkpointer_validation.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_compiler.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_connection.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_derived.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_escape_iql.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_executor.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_functions.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_integration.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_kg_node.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_kg_router.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_langchain.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_langgraph_integration.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_memory_core.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_memory_edge_cases.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_memory_helpers.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_naming.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_operations.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_protocol.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_proxy.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_relation.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_result.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_serde.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_state.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_sync.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/tests/test_types.py +0 -0
- {inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/uv.lock +0 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. Please also get in touch with
|
|
186
|
+
us at legal@inputlayer.ai to let us know you're using the license.
|
|
187
|
+
|
|
188
|
+
Copyright 2024-2026 InputLayer
|
|
189
|
+
|
|
190
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
191
|
+
you may not use this file except in compliance with the License.
|
|
192
|
+
You may obtain a copy of the License at
|
|
193
|
+
|
|
194
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
195
|
+
|
|
196
|
+
Unless required by applicable law or agreed to in writing, software
|
|
197
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
198
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
199
|
+
See the License for the specific language governing permissions and
|
|
200
|
+
limitations under the License.
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
Copyright 2024-2026 InputLayer
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: inputlayer-client-dev
|
|
3
|
-
Version: 0.1.0.
|
|
3
|
+
Version: 0.1.0.dev919
|
|
4
4
|
Summary: Python Object-Logic Mapper for InputLayer knowledge graph engine
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
6
7
|
Requires-Python: >=3.10
|
|
7
8
|
Requires-Dist: pydantic<3,>=2.0
|
|
8
9
|
Requires-Dist: websockets<15,>=12.0
|
|
@@ -50,7 +51,7 @@ pip install inputlayer-client-dev[all] # everything
|
|
|
50
51
|
|
|
51
52
|
Requirements: Python 3.10+ and a running InputLayer server.
|
|
52
53
|
|
|
53
|
-
This also installs the `
|
|
54
|
+
This also installs the `inputlayer-migrate` tool for schema migrations; with the InputLayer product CLI installed, use it as `il migration <verb>`.
|
|
54
55
|
|
|
55
56
|
## Quick Start
|
|
56
57
|
|
|
@@ -424,16 +425,16 @@ The SDK includes a Django-style migration system for production schema managemen
|
|
|
424
425
|
|
|
425
426
|
```bash
|
|
426
427
|
# Generate a migration from your models
|
|
427
|
-
il
|
|
428
|
+
il migration generate --models myapp.models
|
|
428
429
|
|
|
429
430
|
# Apply pending migrations
|
|
430
|
-
il
|
|
431
|
+
il migration apply --url ws://localhost:8080/ws --kg production
|
|
431
432
|
|
|
432
433
|
# Check status
|
|
433
|
-
il
|
|
434
|
+
il migration status --url ws://localhost:8080/ws --kg production
|
|
434
435
|
|
|
435
436
|
# Rollback
|
|
436
|
-
il revert --url ws://localhost:8080/ws --kg production 0001_initial
|
|
437
|
+
il migration revert --url ws://localhost:8080/ws --kg production 0001_initial
|
|
437
438
|
```
|
|
438
439
|
|
|
439
440
|
The autodetector diffs your current Python models against the last migration's state and generates the minimal set of operations (create/drop relations, create/drop/replace rules, create/drop indexes). Each migration file is self-contained with a full state snapshot.
|
|
@@ -518,10 +519,10 @@ The autodetector diffs your current Python models against the last migration's s
|
|
|
518
519
|
|
|
519
520
|
| Command | Description |
|
|
520
521
|
|---------|-------------|
|
|
521
|
-
| `il
|
|
522
|
-
| `il
|
|
523
|
-
| `il revert --url <ws> --kg <name> <target>` | Revert to a target migration |
|
|
524
|
-
| `il
|
|
522
|
+
| `il migration generate --models <module>` | Generate migration from model diff |
|
|
523
|
+
| `il migration apply --url <ws> --kg <name>` | Apply pending migrations |
|
|
524
|
+
| `il migration revert --url <ws> --kg <name> <target>` | Revert to a target migration |
|
|
525
|
+
| `il migration status --url <ws> --kg <name>` | Show applied/pending status |
|
|
525
526
|
|
|
526
527
|
### Aggregation Functions
|
|
527
528
|
|
|
@@ -572,4 +573,4 @@ uv run mypy src/inputlayer/
|
|
|
572
573
|
|
|
573
574
|
## License
|
|
574
575
|
|
|
575
|
-
Apache 2.0
|
|
576
|
+
Apache 2.0. See [LICENSE](./LICENSE). (The InputLayer core server is separately licensed under the Elastic License 2.0.)
|
|
@@ -17,7 +17,7 @@ pip install inputlayer-client-dev[all] # everything
|
|
|
17
17
|
|
|
18
18
|
Requirements: Python 3.10+ and a running InputLayer server.
|
|
19
19
|
|
|
20
|
-
This also installs the `
|
|
20
|
+
This also installs the `inputlayer-migrate` tool for schema migrations; with the InputLayer product CLI installed, use it as `il migration <verb>`.
|
|
21
21
|
|
|
22
22
|
## Quick Start
|
|
23
23
|
|
|
@@ -391,16 +391,16 @@ The SDK includes a Django-style migration system for production schema managemen
|
|
|
391
391
|
|
|
392
392
|
```bash
|
|
393
393
|
# Generate a migration from your models
|
|
394
|
-
il
|
|
394
|
+
il migration generate --models myapp.models
|
|
395
395
|
|
|
396
396
|
# Apply pending migrations
|
|
397
|
-
il
|
|
397
|
+
il migration apply --url ws://localhost:8080/ws --kg production
|
|
398
398
|
|
|
399
399
|
# Check status
|
|
400
|
-
il
|
|
400
|
+
il migration status --url ws://localhost:8080/ws --kg production
|
|
401
401
|
|
|
402
402
|
# Rollback
|
|
403
|
-
il revert --url ws://localhost:8080/ws --kg production 0001_initial
|
|
403
|
+
il migration revert --url ws://localhost:8080/ws --kg production 0001_initial
|
|
404
404
|
```
|
|
405
405
|
|
|
406
406
|
The autodetector diffs your current Python models against the last migration's state and generates the minimal set of operations (create/drop relations, create/drop/replace rules, create/drop indexes). Each migration file is self-contained with a full state snapshot.
|
|
@@ -485,10 +485,10 @@ The autodetector diffs your current Python models against the last migration's s
|
|
|
485
485
|
|
|
486
486
|
| Command | Description |
|
|
487
487
|
|---------|-------------|
|
|
488
|
-
| `il
|
|
489
|
-
| `il
|
|
490
|
-
| `il revert --url <ws> --kg <name> <target>` | Revert to a target migration |
|
|
491
|
-
| `il
|
|
488
|
+
| `il migration generate --models <module>` | Generate migration from model diff |
|
|
489
|
+
| `il migration apply --url <ws> --kg <name>` | Apply pending migrations |
|
|
490
|
+
| `il migration revert --url <ws> --kg <name> <target>` | Revert to a target migration |
|
|
491
|
+
| `il migration status --url <ws> --kg <name>` | Show applied/pending status |
|
|
492
492
|
|
|
493
493
|
### Aggregation Functions
|
|
494
494
|
|
|
@@ -539,4 +539,4 @@ uv run mypy src/inputlayer/
|
|
|
539
539
|
|
|
540
540
|
## License
|
|
541
541
|
|
|
542
|
-
Apache 2.0
|
|
542
|
+
Apache 2.0. See [LICENSE](./LICENSE). (The InputLayer core server is separately licensed under the Elastic License 2.0.)
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "inputlayer-client-dev"
|
|
7
|
-
version = "0.1.0.
|
|
7
|
+
version = "0.1.0.dev919"
|
|
8
8
|
description = "Python Object-Logic Mapper for InputLayer knowledge graph engine"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "Apache-2.0"
|
|
@@ -34,7 +34,7 @@ dev = [
|
|
|
34
34
|
]
|
|
35
35
|
|
|
36
36
|
[project.scripts]
|
|
37
|
-
|
|
37
|
+
inputlayer-migrate = "inputlayer.migrations.cli:main"
|
|
38
38
|
|
|
39
39
|
[tool.hatch.build.targets.wheel]
|
|
40
40
|
packages = ["src/inputlayer"]
|
{inputlayer_client_dev-0.1.0.dev913 → inputlayer_client_dev-0.1.0.dev919}/src/inputlayer/__init__.py
RENAMED
|
@@ -68,8 +68,6 @@ from inputlayer.knowledge_graph import (
|
|
|
68
68
|
WhyResult,
|
|
69
69
|
)
|
|
70
70
|
|
|
71
|
-
# Migrations
|
|
72
|
-
from inputlayer.migrations import Migration
|
|
73
71
|
|
|
74
72
|
# Notifications
|
|
75
73
|
from inputlayer.notifications import NotificationEvent
|
|
@@ -116,8 +114,6 @@ __all__ = [
|
|
|
116
114
|
"KnowledgeGraph",
|
|
117
115
|
"KnowledgeGraphExistsError",
|
|
118
116
|
"KnowledgeGraphNotFoundError",
|
|
119
|
-
# Migrations
|
|
120
|
-
"Migration",
|
|
121
117
|
# Notifications
|
|
122
118
|
"NotificationEvent",
|
|
123
119
|
"PermissionError",
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import Any
|
|
6
|
-
|
|
7
5
|
from inputlayer.migrations.operations import (
|
|
8
6
|
CreateIndex,
|
|
9
7
|
CreateRelation,
|
|
@@ -19,22 +17,6 @@ from inputlayer.migrations.operations import (
|
|
|
19
17
|
from inputlayer.migrations.state import ModelState
|
|
20
18
|
|
|
21
19
|
|
|
22
|
-
class Migration:
|
|
23
|
-
"""Base class for migration files.
|
|
24
|
-
|
|
25
|
-
Subclass as ``M`` in each migration file::
|
|
26
|
-
|
|
27
|
-
class M(Migration):
|
|
28
|
-
dependencies = ["0001_initial"]
|
|
29
|
-
operations = [ops.CreateRelation(...)]
|
|
30
|
-
state = {"relations": {...}, "rules": {...}, "indexes": {}}
|
|
31
|
-
"""
|
|
32
|
-
|
|
33
|
-
dependencies: list[str] = [] # noqa: RUF012
|
|
34
|
-
operations: list[Operation] = [] # noqa: RUF012
|
|
35
|
-
state: dict[str, Any] = {} # noqa: RUF012
|
|
36
|
-
|
|
37
|
-
|
|
38
20
|
__all__ = [
|
|
39
21
|
"CreateIndex",
|
|
40
22
|
"CreateRelation",
|
|
@@ -42,7 +24,6 @@ __all__ = [
|
|
|
42
24
|
"DropIndex",
|
|
43
25
|
"DropRelation",
|
|
44
26
|
"DropRule",
|
|
45
|
-
"Migration",
|
|
46
27
|
"ModelState",
|
|
47
28
|
"Operation",
|
|
48
29
|
"ReplaceRule",
|
|
@@ -205,6 +205,20 @@ def _add_connection_args(parser: argparse.ArgumentParser) -> None:
|
|
|
205
205
|
)
|
|
206
206
|
|
|
207
207
|
|
|
208
|
+
def _add_migrations_dir(sub: argparse.ArgumentParser) -> None:
|
|
209
|
+
"""Accept --migrations-dir after the subcommand as well as before it.
|
|
210
|
+
|
|
211
|
+
Delegating callers (the `il` CLI) always place flags after the
|
|
212
|
+
subcommand. SUPPRESS keeps the subparser from clobbering the value the
|
|
213
|
+
global flag already parsed.
|
|
214
|
+
"""
|
|
215
|
+
sub.add_argument(
|
|
216
|
+
"--migrations-dir",
|
|
217
|
+
default=argparse.SUPPRESS,
|
|
218
|
+
help="Directory for migration files (default: ./migrations)",
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
|
|
208
222
|
def build_parser() -> argparse.ArgumentParser:
|
|
209
223
|
"""Build the CLI argument parser."""
|
|
210
224
|
parser = argparse.ArgumentParser(
|
|
@@ -226,22 +240,26 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
226
240
|
help="Python module path containing models (e.g. myapp.models)",
|
|
227
241
|
)
|
|
228
242
|
make.add_argument("--name", default=None, help="Custom migration name suffix")
|
|
243
|
+
_add_migrations_dir(make)
|
|
229
244
|
make.set_defaults(func=_cmd_makemigrations)
|
|
230
245
|
|
|
231
246
|
# migrate
|
|
232
247
|
mig = subparsers.add_parser("migrate", help="Apply pending migrations")
|
|
233
248
|
_add_connection_args(mig)
|
|
249
|
+
_add_migrations_dir(mig)
|
|
234
250
|
mig.set_defaults(func=_cmd_migrate)
|
|
235
251
|
|
|
236
252
|
# revert
|
|
237
253
|
rev = subparsers.add_parser("revert", help="Revert migrations to a target")
|
|
238
254
|
_add_connection_args(rev)
|
|
255
|
+
_add_migrations_dir(rev)
|
|
239
256
|
rev.add_argument("target", help="Migration name to revert to (e.g. 0001_initial)")
|
|
240
257
|
rev.set_defaults(func=_cmd_revert)
|
|
241
258
|
|
|
242
259
|
# showmigrations
|
|
243
260
|
show = subparsers.add_parser("showmigrations", help="Show migration status")
|
|
244
261
|
_add_connection_args(show)
|
|
262
|
+
_add_migrations_dir(show)
|
|
245
263
|
show.set_defaults(func=_cmd_showmigrations)
|
|
246
264
|
|
|
247
265
|
return parser
|
|
@@ -249,6 +267,9 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
249
267
|
|
|
250
268
|
def main(argv: list[str] | None = None) -> int:
|
|
251
269
|
"""CLI entry point."""
|
|
270
|
+
from inputlayer.exceptions import InputLayerError
|
|
271
|
+
from inputlayer.migrations.errors import MigrationError
|
|
272
|
+
|
|
252
273
|
parser = build_parser()
|
|
253
274
|
args = parser.parse_args(argv)
|
|
254
275
|
|
|
@@ -256,7 +277,11 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
256
277
|
parser.print_help()
|
|
257
278
|
return 1
|
|
258
279
|
|
|
259
|
-
|
|
280
|
+
try:
|
|
281
|
+
return args.func(args)
|
|
282
|
+
except (MigrationError, InputLayerError) as exc:
|
|
283
|
+
print(f"error: {exc}")
|
|
284
|
+
return 1
|
|
260
285
|
|
|
261
286
|
|
|
262
287
|
if __name__ == "__main__":
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Migration errors and the engine-result check.
|
|
2
|
+
|
|
3
|
+
The WebSocket protocol reports engine failures as a result-set with a
|
|
4
|
+
single "error" column rather than an exception, so anything that must
|
|
5
|
+
know whether a statement actually executed has to check for that shape
|
|
6
|
+
explicitly. The migration stack must: silently swallowed errors are how
|
|
7
|
+
the recorder shipped broken (write-only applied-state) in the first
|
|
8
|
+
place.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
from typing import Any
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class MigrationError(Exception):
|
|
17
|
+
"""Raised when a migration fails to load, apply, or revert."""
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def check_engine_result(result: Any, context: str) -> Any:
|
|
21
|
+
"""Raise MigrationError if an execute() result is an engine error frame."""
|
|
22
|
+
columns = list(getattr(result, "columns", None) or [])
|
|
23
|
+
if columns == ["error"]:
|
|
24
|
+
rows = getattr(result, "rows", None) or []
|
|
25
|
+
detail = str(rows[0][0]) if rows and rows[0] else "unknown engine error"
|
|
26
|
+
raise MigrationError(f"engine error while {context}: {detail}")
|
|
27
|
+
return result
|
|
@@ -2,26 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
from inputlayer.migrations.errors import MigrationError, check_engine_result
|
|
5
6
|
from inputlayer.migrations.loader import MigrationInfo
|
|
6
7
|
from inputlayer.migrations.recorder import KGExecutor, MigrationRecorder
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
class MigrationError(Exception):
|
|
10
|
-
"""Raised when a migration fails to apply or revert."""
|
|
9
|
+
__all__ = ["MigrationError", "apply_migration", "migrate", "revert_migration", "revert_to"]
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
def apply_migration(kg: KGExecutor, migration: MigrationInfo) -> None:
|
|
14
|
-
"""Apply a single migration's forward operations.
|
|
13
|
+
"""Apply a single migration's forward operations.
|
|
14
|
+
|
|
15
|
+
Raises MigrationError on the first failing operation. Operations are
|
|
16
|
+
not transactional: earlier operations of this migration stay applied,
|
|
17
|
+
but the migration is NOT recorded as applied, so the failure is
|
|
18
|
+
visible and a re-run picks up where the schema actually is.
|
|
19
|
+
"""
|
|
15
20
|
for op in migration.operations:
|
|
16
21
|
for cmd in op.forward_commands():
|
|
17
|
-
|
|
22
|
+
check_engine_result(
|
|
23
|
+
kg.execute(cmd), f"applying {migration.name} ({op.describe()})"
|
|
24
|
+
)
|
|
18
25
|
|
|
19
26
|
|
|
20
27
|
def revert_migration(kg: KGExecutor, migration: MigrationInfo) -> None:
|
|
21
28
|
"""Revert a single migration's operations in reverse order."""
|
|
22
29
|
for op in reversed(migration.operations):
|
|
23
30
|
for cmd in op.backward_commands():
|
|
24
|
-
|
|
31
|
+
check_engine_result(
|
|
32
|
+
kg.execute(cmd), f"reverting {migration.name} ({op.describe()})"
|
|
33
|
+
)
|
|
25
34
|
|
|
26
35
|
|
|
27
36
|
def migrate(
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"""Migration loader - discover and load JSON migration files from a directory."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
from inputlayer.migrations.errors import MigrationError
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass
|
|
14
|
+
class MigrationInfo:
|
|
15
|
+
"""Metadata about a loaded migration file."""
|
|
16
|
+
|
|
17
|
+
name: str # e.g. "0001_initial"
|
|
18
|
+
number: int # e.g. 1
|
|
19
|
+
filename: str # e.g. "0001_initial.py"
|
|
20
|
+
dependencies: list[str]
|
|
21
|
+
operations: list # list[Operation]
|
|
22
|
+
state: dict[str, Any]
|
|
23
|
+
|
|
24
|
+
@property
|
|
25
|
+
def module_name(self) -> str:
|
|
26
|
+
return self.name
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
_MIGRATION_RE = re.compile(r"^(\d{4})_.+\.json$")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _load_json_migration(entry: Path, name: str, number: int) -> MigrationInfo:
|
|
33
|
+
"""Load a language-neutral JSON migration (the current format)."""
|
|
34
|
+
import json
|
|
35
|
+
|
|
36
|
+
from inputlayer.migrations.operations import operation_from_dict
|
|
37
|
+
from inputlayer.migrations.writer import MIGRATION_FORMAT
|
|
38
|
+
|
|
39
|
+
try:
|
|
40
|
+
document = json.loads(entry.read_text(encoding="utf-8"))
|
|
41
|
+
except json.JSONDecodeError as exc:
|
|
42
|
+
raise MigrationError(f"{entry.name}: invalid JSON: {exc}") from exc
|
|
43
|
+
if not isinstance(document, dict):
|
|
44
|
+
raise MigrationError(f"{entry.name}: migration document must be a JSON object")
|
|
45
|
+
fmt = document.get("format")
|
|
46
|
+
if not isinstance(fmt, int) or fmt > MIGRATION_FORMAT:
|
|
47
|
+
raise MigrationError(
|
|
48
|
+
f"{entry.name}: unsupported migration format {fmt!r} "
|
|
49
|
+
f"(this SDK reads up to {MIGRATION_FORMAT} - upgrade the SDK)"
|
|
50
|
+
)
|
|
51
|
+
state = dict(document.get("state", {}))
|
|
52
|
+
# JSON has no tuples; restore (col, type) pairs so state comparisons in
|
|
53
|
+
# the autodetector see no phantom changes against in-memory model state.
|
|
54
|
+
if "relations" in state:
|
|
55
|
+
state["relations"] = {
|
|
56
|
+
rel: [tuple(col) for col in cols] for rel, cols in state["relations"].items()
|
|
57
|
+
}
|
|
58
|
+
try:
|
|
59
|
+
operations = [operation_from_dict(d) for d in document.get("operations", [])]
|
|
60
|
+
except (KeyError, TypeError, ValueError) as exc:
|
|
61
|
+
raise MigrationError(f"{entry.name}: invalid operation: {exc}") from exc
|
|
62
|
+
return MigrationInfo(
|
|
63
|
+
name=name,
|
|
64
|
+
number=number,
|
|
65
|
+
filename=entry.name,
|
|
66
|
+
dependencies=list(document.get("dependencies", [])),
|
|
67
|
+
operations=operations,
|
|
68
|
+
state=state,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def load_migrations(directory: str | Path) -> list[MigrationInfo]:
|
|
73
|
+
"""Discover and load all migration files from a directory.
|
|
74
|
+
|
|
75
|
+
Migrations are language-neutral JSON documents; that is the only
|
|
76
|
+
format (pre-1.0, no legacy loading). Non-matching files - including
|
|
77
|
+
stray .py files from older SDKs - are ignored. Returns migrations
|
|
78
|
+
sorted by number.
|
|
79
|
+
"""
|
|
80
|
+
directory = Path(directory)
|
|
81
|
+
if not directory.is_dir():
|
|
82
|
+
return []
|
|
83
|
+
|
|
84
|
+
migrations: list[MigrationInfo] = []
|
|
85
|
+
for entry in sorted(directory.iterdir()):
|
|
86
|
+
if not entry.is_file():
|
|
87
|
+
continue
|
|
88
|
+
match = _MIGRATION_RE.match(entry.name)
|
|
89
|
+
if not match:
|
|
90
|
+
continue
|
|
91
|
+
|
|
92
|
+
number = int(match.group(1))
|
|
93
|
+
name = entry.stem # e.g. "0001_initial"
|
|
94
|
+
|
|
95
|
+
migrations.append(_load_json_migration(entry, name, number))
|
|
96
|
+
|
|
97
|
+
migrations.sort(key=lambda m: m.number)
|
|
98
|
+
|
|
99
|
+
# Duplicate names or numbers are always a mistake (a stale legacy .py
|
|
100
|
+
# twin of a regenerated .json, or a merge collision) and previously
|
|
101
|
+
# caused the same migration to be applied twice - destructively for
|
|
102
|
+
# Drop/Replace operations. Refuse loudly.
|
|
103
|
+
by_name: dict[str, str] = {}
|
|
104
|
+
by_number: dict[int, str] = {}
|
|
105
|
+
for m in migrations:
|
|
106
|
+
if m.name in by_name:
|
|
107
|
+
raise MigrationError(
|
|
108
|
+
f"duplicate migration name '{m.name}': {by_name[m.name]} and "
|
|
109
|
+
f"{m.filename} - delete the stale one"
|
|
110
|
+
)
|
|
111
|
+
if m.number in by_number:
|
|
112
|
+
raise MigrationError(
|
|
113
|
+
f"duplicate migration number {m.number:04d}: "
|
|
114
|
+
f"{by_number[m.number]} and {m.filename} - renumber one of them"
|
|
115
|
+
)
|
|
116
|
+
by_name[m.name] = m.filename
|
|
117
|
+
by_number[m.number] = m.filename
|
|
118
|
+
|
|
119
|
+
return migrations
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def get_latest_state(directory: str | Path) -> dict[str, Any]:
|
|
123
|
+
"""Get the state from the most recent migration, or empty if none exist."""
|
|
124
|
+
migrations = load_migrations(directory)
|
|
125
|
+
if not migrations:
|
|
126
|
+
return {"relations": {}, "rules": {}, "indexes": {}}
|
|
127
|
+
return migrations[-1].state
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def get_next_number(directory: str | Path) -> int:
|
|
131
|
+
"""Get the next migration number."""
|
|
132
|
+
migrations = load_migrations(directory)
|
|
133
|
+
if not migrations:
|
|
134
|
+
return 1
|
|
135
|
+
return migrations[-1].number + 1
|