Commit Graph

111 Commits (dccf952ad3924a7cf36ca5486cd2ba090f514008)

Author SHA1 Message Date
Sofus Albert Høgsbro Rose c82862dde9
fix: Implement explicit no-flow w/FlowSignal 2024-04-24 18:36:29 +02:00
Sofus Albert Høgsbro Rose a3defd3c1c
feat: Complete matplotlib plotting system.
The Viz node now detects the shape of the data, and presents compatible
plot options.
Not all are implemented, but a few quite important ones are.

Additionally, a number of dataflow-related bugs were investigated and
fixed. A few were truly damaging, but many simply resulted in gross
inefficiencies - we must be careful declaring BLFields that are updated
in hot loops!

Moreover, it is exceptionally easy to add more as needed, as we analyze
more and more sims.
The only limit is `matplotlib`, which is... well, yeah.

Due to the BLField work, the dynamicness of the Viz node is quite
under control, so there will not be any critical issues there.

The plotting lags (70ms total in the hot loop), but that's actually
entirely fixeable.
It's also entirely the `managed_bl_image`'s fault.
Fixing these inefficiencies will also make Tidy3D's builtin plots
near-realtime, incidentally.

We profiled the following currently:
- 25ms: Creating `fig = plt.subplots`. We can reuse fig per-managed
  image.
- 43ms: The BytesIO roundtrip, including `savefig`. We can instead use
  the Agg backend, `fig.canvas.draw()`, and a `np.frombuffer` to both
  plot directly to the memory location,
- ~3ms: Actual plotting functions in `image_ops`. They are seriously fast.
- ~0ms: Blitting pixels to the Blender image - this was optimized in
  4.1, and it shows; the time to copy the data over is essentially nothing.
2024-04-23 19:27:45 +02:00
Sofus Albert Høgsbro Rose e7d3ecf48e
fix: Crashes on enum changes 2024-04-23 11:51:24 +02:00
Sofus Albert Høgsbro Rose 7fa6e3a3ec
fix: Crashiness of EnumProperty 2024-04-23 10:45:44 +02:00
Sofus Albert Høgsbro Rose f09b58e0e7
fix: BLFields in FilterMath, bug fixes. 2024-04-23 09:30:26 +02:00
Sofus Albert Høgsbro Rose 44d61b5639
feat: Safe, practical BLField.
BLField has gotten a huge facelift, to make it practical to wrangle
properties without the sharp edges.
- All the "special" UI-exposed property types can now be directly
  constructed in a BLField marked with 'prop_ui'.
- The most appropriate internal representation will be chosen to
  represent the attribute based on its type annotation, including sized
  vector-like `bool`, `int`, `float` for `tuple[...]`.
- Static EnumProperties can now be derived from a special `StrEnum`, to
  which a `to_name` and `to_icon` method is attached.
- Dynamic `EnumProperty` can now be used safely, with builtin
  workarounds to the real-world reference-loss-crash (realized
  in the Tidy3D Cloud Task node) and jankiness like empty enum.
- The update method is now fully managed, negating all bugs related to
  improper update callback naming.
- Python-side getter caching is preserved for ui-exposed
  properties, with the help of node/socket base class support for
  passing a `Signal.InvalidateCache` to BLFields that are altered in the
  UI.

The cost to all this niceness is rather low, and arguably, positive:
- Dynamic Enum/String searchers no longer "magically" invoke all the
  time, since the values seen by Blender are cached by the BLField.
- To regenerate the searcher output, an `@on_value_changed` should be
  made by the user to pass `Signal.ResetEnumItems` or
  `Signal.ResetStrSearch` to the `BLField`.
- Since searching is no longer eager, there is no danger of
  out-of-reference strings (which crash Blender from EnumProperty), but
  also a greatly reduced performance problems associated with
  the hot-loop regeneration of EnumProperty strings.
- The base classes are now involved with BLField invalidation, to ensure
  that the getter caches are cleared up when the UI changes. For the
  price of that small indirection (done cheaply with set lookup),
  all attribute lookups are generally done in a single lookup, completely
  avoiding Blender until needed.
- This does represent another increase in confidence wrt. the event
  system's integrity, but so far, that has been a very productive
  direction.

**NOTE**: The entire feature set of BLField is not well tested, and will
likely need adjustments as the codebase is converted to use them.
2024-04-23 07:55:54 +02:00
Sofus Albert Høgsbro Rose b4d6eae036
feat: High-performance math system and depsflow.
Enormously important changes to the data flow semantics and invalidation
rules. Especially significant is the way in which the node graph
produces a deeply composed function, compiles it to optimized machine
code with `jax`, and uses a seperately cached data flow to insert values
into the function from anywhere along the node graph without recompiling
the function.

A critical portion of the math system, namely the unit-aware dimensional
representation, is also finished. The `Data` node socket type now
dynamically reports the dimensional properties of the object flowing
through it, courtesy the use of a seperate data flow for information.
This allows for very high-peformance unit-aware nearest-value indexing built on binary
search.

Also, dependency management is completely ironed out. The `pip install`
process now runs concurrently, and the installation log is parsed in the
background to update a progress bar. This is the foundational work for a
similar concurrent process wrt. Tidy3D progress reporting.
2024-04-22 15:26:15 +02:00
Sofus Albert Høgsbro Rose 9960cd3480
refactor: Big changes to data flow and deps loading 2024-04-19 16:53:24 +02:00
Sofus Albert Høgsbro Rose ff5d71aeff
refactor: More changes to docs/layout 2024-04-18 08:42:53 +02:00
Sofus Albert Høgsbro Rose 8dece384ad
refactor: Moved contracts + fixes 2024-04-17 18:36:11 +02:00
Sofus Albert Høgsbro Rose 6a41683576
refactor: Use cleaner relative import for top-level `utils` 2024-04-17 18:16:14 +02:00
Sofus Albert Høgsbro Rose c6e00dcd7b
refactor: Fixes and movement. 2024-04-17 18:14:14 +02:00
Sofus Albert Høgsbro Rose 29cee2e7a2
fix: Some renamed FlowKinds (not all) 2024-04-17 16:17:13 +02:00
Sofus Albert Høgsbro Rose 76d15b0c92
refactor: Renamed DataFlowKind to FlowKind 2024-04-17 16:06:24 +02:00
Sofus Albert Høgsbro Rose dfeb65feec
feat: Math nodes (non-working) 2024-04-17 16:03:15 +02:00
Sofus Albert Høgsbro Rose 568fc449e8
fix: Caching now (seems to) work robustly.
The serialization routines are fast and effective.
Overall, the node graph feels snappy, and everything updates smoothly.
Logging on the action chain suggests that there aren't extraneous calls,
and that existing calls (ex. no-op previews) are fast.

There will likely be edge cases, and we'll see how it scales - but
for now, let's go with it!
2024-04-15 19:15:20 +02:00
Sofus Albert Høgsbro Rose 269af4ba32
refactor: Ran lint fix 2024-04-15 17:49:53 +02:00
Sofus Albert Høgsbro Rose b5a4b6b0a1
refactor: Common SocketDef owner in `sockets.base` 2024-04-15 17:48:29 +02:00
Sofus Albert Høgsbro Rose 4f6bd8e990
refactor: Revamped serialization (non-working) 2024-04-15 17:46:31 +02:00
Sofus Albert Høgsbro Rose 3def85e24f
refactor: Non-working first-move of serialization logic 2024-04-15 15:21:13 +02:00
Sofus Albert Høgsbro Rose e1f11f6d68
fix: Revalidated cache logic w/KeyedCache.
This especially involved fixing the invalidation logic in
`trigger_action`.
It should now be far more accurate, concise, and performant.

The invalidation check ought still be optimized.
The reason this isn't trivial is because of the loose sockets:
To use our new `@keyed_cache` on a function like `_should_recompute_output_socket`, the loose
socket would also need to do an appropriate invalidation.

Such caching without accounting for invalidation on loose-socket change
would be incorrect.
For now, it seems as though performance is quite good, although it is
unknown whether this will scale to large graphs.

We've also left `kind`-specific invalidation alone for now (maybe
forever).
2024-04-15 15:12:29 +02:00
Sofus Albert Høgsbro Rose 7f2bd2e752
fix: A bug and a crash.
The crash: When a linked loose socket was deleted, the link remained in the
NodeLinkCache, and caused a crash when trying to ask the already-deleted
socket for removal consent. We fixed this by reporting all socket
removals to the node tree, so that links could be correctly removed
independently of link-change calculation.

The bug: The collection getter was cached improperly; Blender ID types
can't just be saved like that. We need to search every time. Performance
seems unaffected at first glance.
2024-04-12 15:58:07 +02:00
Sofus Albert Høgsbro Rose 480679a3c0
refactor: Streamlined graph-update semantics. 2024-04-12 15:39:13 +02:00
Sofus Albert Høgsbro Rose dc76ab7688
fix: Various critical fixes, field preview 2024-04-10 10:46:55 +02:00
Sofus Albert Høgsbro Rose 1d90f9ca7c
fix: Case-insensitive constants search 2024-04-09 10:43:28 +02:00
Sofus Albert Høgsbro Rose 56abb3fb46
feat: Scientific constant node. 2024-04-09 10:37:50 +02:00
Sofus Albert Høgsbro Rose a75f697acd
feat: Robust DataFlowKind w/lazy structures.
This is essential for:
- Representing ranges as bounds
- Arbitrary symbolic/numeric representation of spectral distributions
- Parametric representation and JIT of critical-path procedures.

Unfortunately this broke a lot of nodes in small ways.
Next step is to finish the low-hanging fruit nodes + fix the ones we
have.
2024-04-09 08:50:32 +02:00
Sofus Albert Høgsbro Rose 54dc46290a
feat: Implemented fit of experim. medium data.
It's only good for dispersive media; specifically, a text file with
three floats per line: 'wl n k'.
A custom script was used to convert Maxim's data.

It's very fast, and has a ton of options.
Only the most important are exposed in the node for now.

A bug in MPL plotting aspect ratio declaration on MPL axis object was
fixed by manually running `set_aspect('auto')` after the fact.
It shouldn't do anything, and it doesn't, other than fix the bug :)

Also brought the plotting function of the viewer to parity with
the 3D preview, so the "Auto Plot" button works as expected.
2024-04-08 12:51:09 +02:00
Sofus Albert Høgsbro Rose fd6df15b62
feat: Added Tidy3D file import node 2024-04-08 10:50:47 +02:00
Sofus Albert Høgsbro Rose 627457ff40
docs: Fix rendering of TODO.md 2024-04-08 09:42:31 +02:00
Sofus Albert Høgsbro Rose 619704c46e
feat: Better link/append strategy for GN lookup 2024-04-08 08:38:19 +02:00
Sofus Albert Høgsbro Rose 18abfd4296
docs: Quick docgen streamlining 2024-04-08 08:37:42 +02:00
Sofus Albert Høgsbro Rose 02c63e3b8f
fix: The rabid __mp_main__ segfault. 2024-04-07 18:39:27 +02:00
Sofus Albert Høgsbro Rose c2db40ca6d
fix: Broken GN unit evaluation 2024-04-03 10:13:10 +02:00
Sofus Albert Høgsbro Rose a282d1e7ef
fix: @base event callbacks now use @events 2024-04-02 20:49:57 +02:00
Sofus Albert Høgsbro Rose 01cfc61094
feat: Fixes for cloud tasks, lint run 2024-04-02 20:39:55 +02:00
Sofus Albert Høgsbro Rose 505a12fa25
fix: Bugs related to geonodes, end-of-chain unit conversion 2024-04-02 16:40:02 +02:00
Sofus Albert Høgsbro Rose e080d16893
feat: Proper visualization pathways 2024-04-01 19:28:24 +02:00
Sofus Albert Høgsbro Rose 221d5378e4
feat: ManagedObj Semantics 2024-04-01 16:48:56 +02:00
Sofus Albert Høgsbro Rose a4e764ba21
docs: Updated TODO 2024-03-22 13:51:58 +01:00
Sofus Albert Høgsbro Rose 74e79649fb
feat: Re-Implemented Unit System Node (+ other fixes) 2024-03-22 10:12:14 +01:00
Sofus Albert Høgsbro Rose f54a9031e8
doc: Updated line about instability 2024-03-21 18:54:53 +01:00
Sofus Albert Høgsbro Rose 6f665b891d
feat: Working logging, before- and after-deps.
We have a far more sane approach to nodeps now, which
allows us to essentially have two loggers - one that is
very useful, pretty, and clear, but requires a 'rich'
dependency, and one that is simple.
In this spirit, we factored out services/ too.

We can also set the initial console log level now when
packing the .zip.

There's still work to do with the actual flow for deps
installing / uninstalling.
But it should be far more robust now.

Finally, we have a barebones working `quartodoc`-based docs site.
It's super clever; see <https://github.com/machow/quartodoc>.
As it's "just" a quarto project with some python autodiscovery,
fleshing it out with ex. math, images, diagrams, and so forth
should be exceptionally easy.

As we develop, various linter-guided fixes are being realized.
This will be a long process, best done as we spiff everything up
in preparation for general release.
2024-03-21 18:45:38 +01:00
Sofus Albert Høgsbro Rose 0fbf201d08
chore: Ran code formatter over all files 2024-03-20 12:56:50 +01:00
Sofus Albert Høgsbro Rose be4eec2242
feat: Completely revamped dependency system. 2024-03-20 12:55:40 +01:00
Sofus Albert Høgsbro Rose 59a236f33a
packaging: Initialize virtual 'rye' project. 2024-03-14 13:37:30 +01:00
Sofus Albert Høgsbro Rose e6e7b88959 docs: Added README.md and LICENSE 2024-03-14 12:33:49 +01:00
Sofus Albert Høgsbro Rose 5be3e20e99 feat: Demo-grade simulation feedback loop. 2024-03-13 19:10:54 +01:00
Sofus Albert Høgsbro Rose a19403acf7 feat: Continue to add features.
See README.md.
2024-03-12 09:01:50 +01:00
Sofus Albert Høgsbro Rose 6912344aaf refactor: Continuing large-scale alterations.
The big news is that GeoNodes Structure is now implemented,
under the new and vastly more robust chaining system.

Upload to Tidy3D cloud is tested. Next is Monitors!
2024-03-11 16:35:41 +01:00