nadata 0.1.0__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.
Files changed (133) hide show
  1. nadata-0.1.0/LICENSE +21 -0
  2. nadata-0.1.0/PKG-INFO +191 -0
  3. nadata-0.1.0/README.md +178 -0
  4. nadata-0.1.0/nadata/__init__.py +15 -0
  5. nadata-0.1.0/nadata/api.py +894 -0
  6. nadata-0.1.0/nadata/cli.py +445 -0
  7. nadata-0.1.0/nadata/console.py +486 -0
  8. nadata-0.1.0/nadata/core/__init__.py +0 -0
  9. nadata-0.1.0/nadata/core/database/__init__.py +38 -0
  10. nadata-0.1.0/nadata/core/database/builtins.py +87 -0
  11. nadata-0.1.0/nadata/core/database/database.py +958 -0
  12. nadata-0.1.0/nadata/core/database/dumper.py +285 -0
  13. nadata-0.1.0/nadata/core/database/entity_id.py +142 -0
  14. nadata-0.1.0/nadata/core/database/instance.py +706 -0
  15. nadata-0.1.0/nadata/core/database/network_index.py +1142 -0
  16. nadata-0.1.0/nadata/core/database/page_manager.py +175 -0
  17. nadata-0.1.0/nadata/core/database/persistence/__init__.py +28 -0
  18. nadata-0.1.0/nadata/core/database/persistence/binary_cells.py +1141 -0
  19. nadata-0.1.0/nadata/core/database/persistence/compaction.py +97 -0
  20. nadata-0.1.0/nadata/core/database/persistence/dumper.py +798 -0
  21. nadata-0.1.0/nadata/core/database/persistence/lazy_instances.py +1537 -0
  22. nadata-0.1.0/nadata/core/database/persistence/loader.py +424 -0
  23. nadata-0.1.0/nadata/core/database/persistence/record_store.py +228 -0
  24. nadata-0.1.0/nadata/core/database/persistence/serialization.py +605 -0
  25. nadata-0.1.0/nadata/core/database/query_engine.py +222 -0
  26. nadata-0.1.0/nadata/core/database/queryset.py +508 -0
  27. nadata-0.1.0/nadata/core/database/reconciliation.py +287 -0
  28. nadata-0.1.0/nadata/core/database/slotted_page.py +190 -0
  29. nadata-0.1.0/nadata/core/database/spatial_index.py +1080 -0
  30. nadata-0.1.0/nadata/core/expressions/__init__.py +44 -0
  31. nadata-0.1.0/nadata/core/expressions/autograd.py +2909 -0
  32. nadata-0.1.0/nadata/core/expressions/builtins.py +4673 -0
  33. nadata-0.1.0/nadata/core/expressions/expression.py +2658 -0
  34. nadata-0.1.0/nadata/core/expressions/io_builtins.py +972 -0
  35. nadata-0.1.0/nadata/core/expressions/scope.py +336 -0
  36. nadata-0.1.0/nadata/core/expressions/statement.py +953 -0
  37. nadata-0.1.0/nadata/core/struct/__init__.py +14 -0
  38. nadata-0.1.0/nadata/core/struct/struct.py +218 -0
  39. nadata-0.1.0/nadata/core/struct/struct_attribute.py +100 -0
  40. nadata-0.1.0/nadata/core/struct/struct_method.py +324 -0
  41. nadata-0.1.0/nadata/core/types/__init__.py +33 -0
  42. nadata-0.1.0/nadata/core/types/bits/__init__.py +0 -0
  43. nadata-0.1.0/nadata/core/types/bits/bits.py +686 -0
  44. nadata-0.1.0/nadata/core/types/home_types/__init__.py +19 -0
  45. nadata-0.1.0/nadata/core/types/home_types/color.py +102 -0
  46. nadata-0.1.0/nadata/core/types/home_types/coordinate.py +1008 -0
  47. nadata-0.1.0/nadata/core/types/home_types/datetime.py +362 -0
  48. nadata-0.1.0/nadata/core/types/home_types/geogrid.py +92 -0
  49. nadata-0.1.0/nadata/core/types/home_types/geometry.py +1223 -0
  50. nadata-0.1.0/nadata/core/types/home_types/graph.py +0 -0
  51. nadata-0.1.0/nadata/core/types/home_types/planet.py +359 -0
  52. nadata-0.1.0/nadata/core/types/home_types/sea_level.py +98 -0
  53. nadata-0.1.0/nadata/core/types/home_types/vec.py +0 -0
  54. nadata-0.1.0/nadata/core/types/types.py +1345 -0
  55. nadata-0.1.0/nadata/core/values/__init__.py +14 -0
  56. nadata-0.1.0/nadata/core/values/values.py +1568 -0
  57. nadata-0.1.0/nadata/parser/__init__.py +0 -0
  58. nadata-0.1.0/nadata/parser/expressions/__init__.py +6 -0
  59. nadata-0.1.0/nadata/parser/expressions/dependencies.py +318 -0
  60. nadata-0.1.0/nadata/parser/expressions/expression_parser.py +993 -0
  61. nadata-0.1.0/nadata/parser/expressions/splitter.py +98 -0
  62. nadata-0.1.0/nadata/parser/expressions/statement_parser.py +1425 -0
  63. nadata-0.1.0/nadata/parser/expressions/tokenizer.py +402 -0
  64. nadata-0.1.0/nadata/parser/expressions/type_parser.py +187 -0
  65. nadata-0.1.0/nadata/parser/nadata_loader/__init__.py +8 -0
  66. nadata-0.1.0/nadata/parser/nadata_loader/loader.py +951 -0
  67. nadata-0.1.0/nadata/parser/nastruct_parser/__init__.py +0 -0
  68. nadata-0.1.0/nadata/parser/nastruct_parser/declaration.py +105 -0
  69. nadata-0.1.0/nadata/parser/nastruct_parser/imports.py +164 -0
  70. nadata-0.1.0/nadata/parser/nastruct_parser/nastruct_parser.py +209 -0
  71. nadata-0.1.0/nadata/parser/nastruct_parser/parse_attributes.py +149 -0
  72. nadata-0.1.0/nadata/parser/nastruct_parser/parse_callables.py +436 -0
  73. nadata-0.1.0/nadata/parser/nastruct_parser/parse_expression.py +59 -0
  74. nadata-0.1.0/nadata/parser/nastruct_parser/parse_structs.py +206 -0
  75. nadata-0.1.0/nadata/parser/nastruct_parser/parser_state.py +84 -0
  76. nadata-0.1.0/nadata/parser/nastruct_parser/resolver.py +1412 -0
  77. nadata-0.1.0/nadata/parser/nastruct_parser/struct_body_state.py +50 -0
  78. nadata-0.1.0/nadata/parser/nastruct_parser/tmp_structs.py +156 -0
  79. nadata-0.1.0/nadata/parser/utils/__init__.py +20 -0
  80. nadata-0.1.0/nadata/parser/utils/brackets.py +252 -0
  81. nadata-0.1.0/nadata/parser/utils/comments_remove.py +149 -0
  82. nadata-0.1.0/nadata/parser/utils/identifiers.py +121 -0
  83. nadata-0.1.0/nadata/session.py +868 -0
  84. nadata-0.1.0/nadata.egg-info/PKG-INFO +191 -0
  85. nadata-0.1.0/nadata.egg-info/SOURCES.txt +131 -0
  86. nadata-0.1.0/nadata.egg-info/dependency_links.txt +1 -0
  87. nadata-0.1.0/nadata.egg-info/entry_points.txt +2 -0
  88. nadata-0.1.0/nadata.egg-info/requires.txt +4 -0
  89. nadata-0.1.0/nadata.egg-info/top_level.txt +1 -0
  90. nadata-0.1.0/pyproject.toml +35 -0
  91. nadata-0.1.0/setup.cfg +4 -0
  92. nadata-0.1.0/tests/test_api.py +381 -0
  93. nadata-0.1.0/tests/test_autograd.py +1507 -0
  94. nadata-0.1.0/tests/test_binary_persistence.py +532 -0
  95. nadata-0.1.0/tests/test_builtins.py +227 -0
  96. nadata-0.1.0/tests/test_cli.py +170 -0
  97. nadata-0.1.0/tests/test_console.py +150 -0
  98. nadata-0.1.0/tests/test_const_dims.py +383 -0
  99. nadata-0.1.0/tests/test_core.py +173 -0
  100. nadata-0.1.0/tests/test_database.py +344 -0
  101. nadata-0.1.0/tests/test_error_handling.py +231 -0
  102. nadata-0.1.0/tests/test_examples.py +307 -0
  103. nadata-0.1.0/tests/test_expression_parser.py +710 -0
  104. nadata-0.1.0/tests/test_expressions.py +309 -0
  105. nadata-0.1.0/tests/test_geodesy.py +1025 -0
  106. nadata-0.1.0/tests/test_geogrid.py +599 -0
  107. nadata-0.1.0/tests/test_geometry.py +896 -0
  108. nadata-0.1.0/tests/test_grammar.py +319 -0
  109. nadata-0.1.0/tests/test_imports.py +287 -0
  110. nadata-0.1.0/tests/test_indexing.py +327 -0
  111. nadata-0.1.0/tests/test_io.py +805 -0
  112. nadata-0.1.0/tests/test_language_features.py +528 -0
  113. nadata-0.1.0/tests/test_loops.py +506 -0
  114. nadata-0.1.0/tests/test_membership.py +307 -0
  115. nadata-0.1.0/tests/test_memory.py +976 -0
  116. nadata-0.1.0/tests/test_nadata_loader.py +248 -0
  117. nadata-0.1.0/tests/test_network.py +538 -0
  118. nadata-0.1.0/tests/test_nid.py +442 -0
  119. nadata-0.1.0/tests/test_osm.py +390 -0
  120. nadata-0.1.0/tests/test_parser.py +378 -0
  121. nadata-0.1.0/tests/test_persistence.py +669 -0
  122. nadata-0.1.0/tests/test_queryset.py +220 -0
  123. nadata-0.1.0/tests/test_queue_types.py +430 -0
  124. nadata-0.1.0/tests/test_reconciliation.py +308 -0
  125. nadata-0.1.0/tests/test_resolution.py +470 -0
  126. nadata-0.1.0/tests/test_session.py +592 -0
  127. nadata-0.1.0/tests/test_set_type.py +376 -0
  128. nadata-0.1.0/tests/test_spatial_index.py +831 -0
  129. nadata-0.1.0/tests/test_spatial_tensor.py +459 -0
  130. nadata-0.1.0/tests/test_strings_and_indexes.py +295 -0
  131. nadata-0.1.0/tests/test_target_assignment.py +361 -0
  132. nadata-0.1.0/tests/test_tensor_ops.py +1807 -0
  133. nadata-0.1.0/tests/test_tensor_slicing.py +356 -0
nadata-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Nathan Cerisara
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
nadata-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,191 @@
1
+ Metadata-Version: 2.4
2
+ Name: nadata
3
+ Version: 0.1.0
4
+ Summary: A declarative data schema and object-graph modeling framework
5
+ License-Expression: MIT
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Provides-Extra: dev
10
+ Requires-Dist: pytest>=8.0; extra == "dev"
11
+ Requires-Dist: mypy>=1.8; extra == "dev"
12
+ Dynamic: license-file
13
+
14
+ # Nadata
15
+
16
+ [![CI](https://github.com/nath54/Nadata/actions/workflows/ci.yml/badge.svg)](https://github.com/nath54/Nadata/actions/workflows/ci.yml)
17
+
18
+ **Nadata** is a declarative data schema and object-graph framework with its own
19
+ language. You describe your data model in `.nastruct` schema files, populate it
20
+ in `.nadata` data files, and get a typed, queryable, persistent object graph —
21
+ usable from the command line or as an embedded Python library.
22
+
23
+ ```text
24
+ # structs.nastruct — the model
25
+ class Human {
26
+ name: Str;
27
+ birthday: DateTime = DateTime();
28
+
29
+ @age(now: DateTime = DateTime.now()) -> DateTime {
30
+ return now - self.birthday;
31
+ }
32
+ }
33
+
34
+ # data.nadata — the data
35
+ tom = Human(name="Tom", birthday=DateTime(d=12, m=4, y=2003));
36
+
37
+ print("Tom is an adult:", tom.age(DateTime.now()).year >= 18);
38
+ Array[Human] adults = Human.where((h: Human) -> h.age(DateTime.now()).year >= 18);
39
+ ```
40
+
41
+ ## Features
42
+
43
+ - **Typed schema language** — structs, inheritance, attributes with defaults,
44
+ `const` bind-once attributes, methods and computed properties, standalone
45
+ functions; `import "...";` shares schema libraries across projects
46
+ - **String library and hash indexes** — typed string members (`split`,
47
+ `join`, `replace`, `contains`, ...), and opt-in per-attribute hash
48
+ indexes (`index(Human, "email")` + `get_by(Human, "email", x)`) with
49
+ automatic insert / update / removal maintenance — O(1) equality
50
+ lookups instead of full scans
51
+ - **Rich type system** — sized integers/floats (`Int32`, `UFloat16`, ...),
52
+ `Str`, `Bool`, `DateTime`, `Color`, `Array[T]`, `Dict[K, V]`, `Set[T]`,
53
+ `Queue[T]` / `PriorityQueue[T, P]`, sparse spatial grids
54
+ (`GridSquare2D[T]`, `GridHex2D[T]`, `GridCube3D[T]`), shape-checked
55
+ `Tensor[T, d1, ...]` with symbolic dims bound to `const` attributes,
56
+ entity references; indexing (`arr[0]`,
57
+ `dict["k"]`) and string concatenation
58
+ - **Error handling** — `raise "message";` and `try { ... } catch (err) { ... }`
59
+ in scripts and method bodies; runtime errors (indexing, I/O builtins)
60
+ are catchable too, while `return` / `break` / `continue` pass through
61
+ - **Declarative data files** — forward and circular references, script
62
+ statements, `print`, chained polymorphic queries
63
+ - **Runtime introspection** — `elt.id`, `type(x)`, `elt.list_attr()` /
64
+ `list_methods()`, schema-constrained `getattr`/`setattr`, and database-wide
65
+ `schema_classes()` / `schema_functions()`
66
+ - **Persistence** — whole-database dumps, dirty-only delta appends, and
67
+ removal tombstones to a single `.ndb` file
68
+ - **Bounded memory** — disk-backed lazy rows (~50 bytes/row index), a
69
+ bounded LRU decode cache with clean-only eviction, `pin`/`unpin`,
70
+ `flush`/`clear_cache`, and `remove_from_db` from scripts — stream
71
+ millions of rows while the model stays hot
72
+ - **Autograd and training** — tape-based reverse-mode differentiation on Float
73
+ tensors (arithmetic, `matmul`, reductions, shape ops, `gather`, slices,
74
+ `relu`), seeded data partitioning for train/valid/test splits, and built-in
75
+ `SGD` — train models end-to-end in `.nadata` scripts
76
+ - **Sessions & identity** — a project folder is a session: `#init` seeds once
77
+ per world, `#auto` syncs every open, `#manual` scripts take parameters
78
+ (`#manual(lr: Float = 0.05)`), and `nid = "name"` gives instances stable,
79
+ updatable identity (`get_by_nid`, `nids`, `first`/`last`) — schema files
80
+ re-merge on every open, and schema evolution is reconciled against
81
+ persisted rows (removed attributes are dropped; type changes are
82
+ reported, never fatal). I/O builtins (`read_json`, `write_csv`,
83
+ `file_hash`, ...) resolve against the project root, with
84
+ `get_setting`/`set_setting` freshness markers
85
+ - **Interactive console** — `nadata console <path>` REPL over any loaded
86
+ database, with persistent state and expression echoing
87
+ - **Python API** — load, query, mutate, execute raw source, persist
88
+ - **Zero dependencies** — pure Python 3.10+
89
+
90
+ ## Installation
91
+
92
+ ```bash
93
+ git clone <repository-url>
94
+ cd Nadata
95
+ pip install -e .
96
+ pip install -e .[dev] # optional: pytest + mypy for development
97
+ ```
98
+
99
+ ## Quick start
100
+
101
+ ```bash
102
+ # Run a project (schema + data) and execute its scripts
103
+ nadata run examples/ex0_simple
104
+
105
+ # Print a summary of a project or a saved .ndb database
106
+ nadata info examples/ex0_simple
107
+ nadata info store.ndb
108
+
109
+ # Persist a project to a single database file
110
+ nadata dump examples/ex0_simple store.ndb
111
+
112
+ # Explore it interactively (works on folders and .ndb files)
113
+ nadata console examples/ex0_simple
114
+ nadata console store.ndb
115
+ ```
116
+
117
+ Or from Python:
118
+
119
+ ```python
120
+ import nadata
121
+
122
+ app = nadata.Nadata.load("./examples/ex0_simple")
123
+
124
+ print(app.get_attribute("tom", "birthplace")) # Paris
125
+ print(app.count("Human")) # 3
126
+
127
+ app.dump("store.ndb") # persist
128
+ ```
129
+
130
+ ## Documentation
131
+
132
+ | Document | Contents |
133
+ |---|---|
134
+ | [docs/tutorial.md](docs/tutorial.md) | Step-by-step tutorial: your first project |
135
+ | [docs/syntax.md](docs/syntax.md) | Full language reference: rules and syntax |
136
+ | [docs/architecture.md](docs/architecture.md) | How the engine works, stage by stage |
137
+ | [docs/api.md](docs/api.md) | Python API and CLI reference |
138
+ | [docs/persistence.md](docs/persistence.md) | The `.ndb` format, dumps and incremental saves |
139
+ | [docs/benchmarks.md](docs/benchmarks.md) | Engine stage profiling, synthetic benchmarks, SQLite comparison |
140
+ | [docs/development.md](docs/development.md) | Code style, testing, contributing |
141
+
142
+ ## Examples
143
+
144
+ The `examples/` folder contains self-contained projects, from basics to
145
+ edge cases:
146
+
147
+ | Example | Demonstrates |
148
+ |---|---|
149
+ | `ex0_simple` | Family graph: inheritance, methods, forward refs, queries |
150
+ | `ex1_primitives` | Every sized integer/float type and boundary values |
151
+ | `ex2_inheritance` | Circular references, polymorphic queries |
152
+ | `ex3_collections` | Nested arrays, dictionaries, `Color`, `DateTime` math |
153
+ | `ex4_expressions` | `if`/`else`, boolean operators, local declarations |
154
+ | `ex5_edge_cases` | Parser edge cases: comments, spacing, empty constructs |
155
+ | `ex6_loops_collections` | Loops (`for-in`, C-style, `while`), fuel guards, collections |
156
+ | `ex7_queues_sets` | FIFO / priority queues, typed sets, membership probes |
157
+ | `ex8_grids_tensors` | Sparse spatial grids (square/hex/cube), shape-checked tensors |
158
+ | `ex9_constants` | `const` bind-once attributes, symbolic tensor dims |
159
+ | `ex10_cnn` | Conv1d/conv2d, pooling, and a basic convolutional neural network |
160
+ | `ex11_transformer` | A minimal transformer block: attention, LayerNorm, feed-forward, `topk` sampling |
161
+ | `ex12_optimizer_checkpoint` | Training a gelu network with Adam, checkpointing optimizer state to a sidecar file, and resuming from it |
162
+
163
+ ## Editor support
164
+
165
+ Syntax highlighting for `.nastruct` and `.nadata` files ships as a
166
+ VS Code / VSCodium extension in
167
+ [`editors/vscode-nadata`](editors/vscode-nadata). `.vsix` packages are
168
+ not stored in git — build one and install it:
169
+
170
+ ```bash
171
+ cd editors/vscode-nadata
172
+ npx -y @vscode/vsce package --allow-missing-repository # -> nadata-support-<version>.vsix
173
+ code --install-extension nadata-support-<version>.vsix
174
+ ```
175
+
176
+ Packaged releases attach the current `.vsix` to the matching git tag.
177
+
178
+ A sync test (`tests/test_grammar.py`) keeps the grammar aligned with the
179
+ language: it fails whenever a builtin type, keyword, or scope is missing.
180
+
181
+ ## Development
182
+
183
+ ```bash
184
+ python -m pytest tests/ -q # run the test suite
185
+ python -m mypy nadata/ # type check (strict)
186
+ python -m scripts.inspect_parse examples/ex0_simple # inspect the parse IR
187
+ ```
188
+
189
+ ## License
190
+
191
+ MIT — see [LICENSE](LICENSE).
nadata-0.1.0/README.md ADDED
@@ -0,0 +1,178 @@
1
+ # Nadata
2
+
3
+ [![CI](https://github.com/nath54/Nadata/actions/workflows/ci.yml/badge.svg)](https://github.com/nath54/Nadata/actions/workflows/ci.yml)
4
+
5
+ **Nadata** is a declarative data schema and object-graph framework with its own
6
+ language. You describe your data model in `.nastruct` schema files, populate it
7
+ in `.nadata` data files, and get a typed, queryable, persistent object graph —
8
+ usable from the command line or as an embedded Python library.
9
+
10
+ ```text
11
+ # structs.nastruct — the model
12
+ class Human {
13
+ name: Str;
14
+ birthday: DateTime = DateTime();
15
+
16
+ @age(now: DateTime = DateTime.now()) -> DateTime {
17
+ return now - self.birthday;
18
+ }
19
+ }
20
+
21
+ # data.nadata — the data
22
+ tom = Human(name="Tom", birthday=DateTime(d=12, m=4, y=2003));
23
+
24
+ print("Tom is an adult:", tom.age(DateTime.now()).year >= 18);
25
+ Array[Human] adults = Human.where((h: Human) -> h.age(DateTime.now()).year >= 18);
26
+ ```
27
+
28
+ ## Features
29
+
30
+ - **Typed schema language** — structs, inheritance, attributes with defaults,
31
+ `const` bind-once attributes, methods and computed properties, standalone
32
+ functions; `import "...";` shares schema libraries across projects
33
+ - **String library and hash indexes** — typed string members (`split`,
34
+ `join`, `replace`, `contains`, ...), and opt-in per-attribute hash
35
+ indexes (`index(Human, "email")` + `get_by(Human, "email", x)`) with
36
+ automatic insert / update / removal maintenance — O(1) equality
37
+ lookups instead of full scans
38
+ - **Rich type system** — sized integers/floats (`Int32`, `UFloat16`, ...),
39
+ `Str`, `Bool`, `DateTime`, `Color`, `Array[T]`, `Dict[K, V]`, `Set[T]`,
40
+ `Queue[T]` / `PriorityQueue[T, P]`, sparse spatial grids
41
+ (`GridSquare2D[T]`, `GridHex2D[T]`, `GridCube3D[T]`), shape-checked
42
+ `Tensor[T, d1, ...]` with symbolic dims bound to `const` attributes,
43
+ entity references; indexing (`arr[0]`,
44
+ `dict["k"]`) and string concatenation
45
+ - **Error handling** — `raise "message";` and `try { ... } catch (err) { ... }`
46
+ in scripts and method bodies; runtime errors (indexing, I/O builtins)
47
+ are catchable too, while `return` / `break` / `continue` pass through
48
+ - **Declarative data files** — forward and circular references, script
49
+ statements, `print`, chained polymorphic queries
50
+ - **Runtime introspection** — `elt.id`, `type(x)`, `elt.list_attr()` /
51
+ `list_methods()`, schema-constrained `getattr`/`setattr`, and database-wide
52
+ `schema_classes()` / `schema_functions()`
53
+ - **Persistence** — whole-database dumps, dirty-only delta appends, and
54
+ removal tombstones to a single `.ndb` file
55
+ - **Bounded memory** — disk-backed lazy rows (~50 bytes/row index), a
56
+ bounded LRU decode cache with clean-only eviction, `pin`/`unpin`,
57
+ `flush`/`clear_cache`, and `remove_from_db` from scripts — stream
58
+ millions of rows while the model stays hot
59
+ - **Autograd and training** — tape-based reverse-mode differentiation on Float
60
+ tensors (arithmetic, `matmul`, reductions, shape ops, `gather`, slices,
61
+ `relu`), seeded data partitioning for train/valid/test splits, and built-in
62
+ `SGD` — train models end-to-end in `.nadata` scripts
63
+ - **Sessions & identity** — a project folder is a session: `#init` seeds once
64
+ per world, `#auto` syncs every open, `#manual` scripts take parameters
65
+ (`#manual(lr: Float = 0.05)`), and `nid = "name"` gives instances stable,
66
+ updatable identity (`get_by_nid`, `nids`, `first`/`last`) — schema files
67
+ re-merge on every open, and schema evolution is reconciled against
68
+ persisted rows (removed attributes are dropped; type changes are
69
+ reported, never fatal). I/O builtins (`read_json`, `write_csv`,
70
+ `file_hash`, ...) resolve against the project root, with
71
+ `get_setting`/`set_setting` freshness markers
72
+ - **Interactive console** — `nadata console <path>` REPL over any loaded
73
+ database, with persistent state and expression echoing
74
+ - **Python API** — load, query, mutate, execute raw source, persist
75
+ - **Zero dependencies** — pure Python 3.10+
76
+
77
+ ## Installation
78
+
79
+ ```bash
80
+ git clone <repository-url>
81
+ cd Nadata
82
+ pip install -e .
83
+ pip install -e .[dev] # optional: pytest + mypy for development
84
+ ```
85
+
86
+ ## Quick start
87
+
88
+ ```bash
89
+ # Run a project (schema + data) and execute its scripts
90
+ nadata run examples/ex0_simple
91
+
92
+ # Print a summary of a project or a saved .ndb database
93
+ nadata info examples/ex0_simple
94
+ nadata info store.ndb
95
+
96
+ # Persist a project to a single database file
97
+ nadata dump examples/ex0_simple store.ndb
98
+
99
+ # Explore it interactively (works on folders and .ndb files)
100
+ nadata console examples/ex0_simple
101
+ nadata console store.ndb
102
+ ```
103
+
104
+ Or from Python:
105
+
106
+ ```python
107
+ import nadata
108
+
109
+ app = nadata.Nadata.load("./examples/ex0_simple")
110
+
111
+ print(app.get_attribute("tom", "birthplace")) # Paris
112
+ print(app.count("Human")) # 3
113
+
114
+ app.dump("store.ndb") # persist
115
+ ```
116
+
117
+ ## Documentation
118
+
119
+ | Document | Contents |
120
+ |---|---|
121
+ | [docs/tutorial.md](docs/tutorial.md) | Step-by-step tutorial: your first project |
122
+ | [docs/syntax.md](docs/syntax.md) | Full language reference: rules and syntax |
123
+ | [docs/architecture.md](docs/architecture.md) | How the engine works, stage by stage |
124
+ | [docs/api.md](docs/api.md) | Python API and CLI reference |
125
+ | [docs/persistence.md](docs/persistence.md) | The `.ndb` format, dumps and incremental saves |
126
+ | [docs/benchmarks.md](docs/benchmarks.md) | Engine stage profiling, synthetic benchmarks, SQLite comparison |
127
+ | [docs/development.md](docs/development.md) | Code style, testing, contributing |
128
+
129
+ ## Examples
130
+
131
+ The `examples/` folder contains self-contained projects, from basics to
132
+ edge cases:
133
+
134
+ | Example | Demonstrates |
135
+ |---|---|
136
+ | `ex0_simple` | Family graph: inheritance, methods, forward refs, queries |
137
+ | `ex1_primitives` | Every sized integer/float type and boundary values |
138
+ | `ex2_inheritance` | Circular references, polymorphic queries |
139
+ | `ex3_collections` | Nested arrays, dictionaries, `Color`, `DateTime` math |
140
+ | `ex4_expressions` | `if`/`else`, boolean operators, local declarations |
141
+ | `ex5_edge_cases` | Parser edge cases: comments, spacing, empty constructs |
142
+ | `ex6_loops_collections` | Loops (`for-in`, C-style, `while`), fuel guards, collections |
143
+ | `ex7_queues_sets` | FIFO / priority queues, typed sets, membership probes |
144
+ | `ex8_grids_tensors` | Sparse spatial grids (square/hex/cube), shape-checked tensors |
145
+ | `ex9_constants` | `const` bind-once attributes, symbolic tensor dims |
146
+ | `ex10_cnn` | Conv1d/conv2d, pooling, and a basic convolutional neural network |
147
+ | `ex11_transformer` | A minimal transformer block: attention, LayerNorm, feed-forward, `topk` sampling |
148
+ | `ex12_optimizer_checkpoint` | Training a gelu network with Adam, checkpointing optimizer state to a sidecar file, and resuming from it |
149
+
150
+ ## Editor support
151
+
152
+ Syntax highlighting for `.nastruct` and `.nadata` files ships as a
153
+ VS Code / VSCodium extension in
154
+ [`editors/vscode-nadata`](editors/vscode-nadata). `.vsix` packages are
155
+ not stored in git — build one and install it:
156
+
157
+ ```bash
158
+ cd editors/vscode-nadata
159
+ npx -y @vscode/vsce package --allow-missing-repository # -> nadata-support-<version>.vsix
160
+ code --install-extension nadata-support-<version>.vsix
161
+ ```
162
+
163
+ Packaged releases attach the current `.vsix` to the matching git tag.
164
+
165
+ A sync test (`tests/test_grammar.py`) keeps the grammar aligned with the
166
+ language: it fails whenever a builtin type, keyword, or scope is missing.
167
+
168
+ ## Development
169
+
170
+ ```bash
171
+ python -m pytest tests/ -q # run the test suite
172
+ python -m mypy nadata/ # type check (strict)
173
+ python -m scripts.inspect_parse examples/ex0_simple # inspect the parse IR
174
+ ```
175
+
176
+ ## License
177
+
178
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,15 @@
1
+ """
2
+ Nadata package entry point.
3
+
4
+ Re-exports the high level Nadata facade and the CLI main function so the
5
+ library can be imported (import nadata) and the console script installed
6
+ (nadata = nadata.cli:main) from a single package.
7
+ """
8
+
9
+ # Import Modules
10
+ from nadata.api import Nadata
11
+ from nadata.cli import main
12
+
13
+ __all__ = ["Nadata", "main", "__version__"]
14
+
15
+ __version__ = "0.1.0"