* test_potentially_dirty_substates: when a state named State should be computed
Catch a regression introduced in 0.4.3a1
* _potentially_dirty_substates: qualify substate name
When looking up substate classes, ensure the qualified name is used to avoid
issues with same-named substates.
* initial attempt at writing test for urls
* turn it into a pytest test
* fix precommit and add wrong url to make sure test work
* fix darglint error and fix url set error
* black error
* add to test .md files in reflex as well
* update to fix masen comment
* black formatting
* Fix trailing slash in reflex/state.py
---------
Co-authored-by: Tom Gotsman <tomgotsman@Toms-MacBook-Pro.local>
Co-authored-by: Tom Gotsman <tomgotsman@toms-mbp.lan>
Co-authored-by: Masen Furer <m_github@0x26.net>
* added code for computed backend vars
* fixed formatting issues
* fix small bug
* fixes ruff issue
* fixed black issue
* augment test for backend computed var
---------
Co-authored-by: Masen Furer <m_github@0x26.net>
* add pulser for connection + adjust condition for connnection_modal
* update style for connection pulser
* rename connectError to connectErrors
* resolve update bug of connectErrors
* fix pulse definition
* rollback pulse definition
* Define WifiOffPulse icon as its own component
Attach the pulse keyframes and imports to the icon itself so that the code gets
properly included in stateful_components.js when it is used.
* limit number of errors in memory
---------
Co-authored-by: Masen Furer <m_github@0x26.net>
* WiP get_state
* Refactor get_state fast path
Rudimentary protection for state instance access from a background task
(StateProxy)
* retain dirty substate marking per `_mark_dirty` call to avoid test changes
* Find common ancestor by part instead of by character
Fix StateProxy for substates and parent_state attributes (have to handle in
__getattr__, not property)
Fix type annotation for `get_state`
* test_state: workflow test for `get_state` functionality
* Do not reset _always_dirty_substates when adding vars
Reset the substate tracking only when the class is instantiated.
* test_state_tree: test substate access in a larger state tree
Ensure that `get_state` returns the proper "branch" of the state tree depending
on what substate is requested.
* test_format: fixup broken tests from adding substates of TestState
* Fix flaky integration tests with more polling
* AppHarness: reset _always_dirty_substates on rx.State
* RuntimeError unless State is instantiated with _reflex_internal_init=True
Avoid user errors trying to directly instantiate State classes
* Helper functions for _substate_key and _split_substate_key
Unify the implementation of generating and decoding the token + state name
format used for redis state sharding.
* StateManagerRedis: use create_task in get_state and set_state
read and write substates concurrently (allow redis to shine)
* test_state_inheritance: use polling cuz life too short for flaky tests
kthnxbai ❤️
* Move _is_testing_env to reflex.utils.exec.is_testing_env
Reuse the code in app.py
* Break up `BaseState.get_state` and friends into separate methods
* Add test case for pre-fetching cached var dependency
* Move on_load_internal and update_vars_internal to substates
Avoid loading the entire state tree to process these common internal events. If
the state tree is very large, this allow page navigation to occur more quickly.
Pre-fetch substates that contain cached vars, as they may need to be recomputed
if certain vars change.
* Do not copy ROUTER_DATA into all substates.
This is a waste of time and memory, and can be handled via a special case in
__getattribute__
* Track whether State instance _was_touched
Avoid wasting time serializing states that have no modifications
* Do not persist states in `StateManagerRedis.get_state`
Wait until the state is actually modified, and then persist it as part of `set_state`.
Factor out common logic into helper methods for readability and to reduce
duplication of common logic.
To avoid having to recursively call `get_state`, which would require persisting
the instance and then getting it again, some of the initialization logic
regarding parent_state and substates is duplicated when creating a new
instance. This is for performance reasons.
* Remove stray print()
* context.js.jinja2: fix check for empty local storage / cookie vars
* Add comments for onLoadInternalEvent and initialEvents
* nit: typo
* split _get_was_touched into _update_was_touched
Improve clarity in cases where _get_was_touched was being called for its side
effects only.
* Remove extraneous information from incorrect State instantiation error
* Update missing redis exception message
* fix inherited backend var deps
* fixing the real issue with @masenf
* Revert "fix inherited backend var deps"
This reverts commit 894e3e14ac.
* python 3.8
* initial values for computed vars draft
* add tests, add computed_var overloads
* fix darglint
* pass initial to substates when calling dict
* add tests for for child states
* format black
* allow None as initial value
* rename runtime_only to raises_at_runtime
* cleanup unused arguments of ComputedVars
* refactor cached_var to be partial of computed_var
* benchmarks.yml: skip benchmarking if the DATABASE_URL is not set
* try to expand the value
* workaround secrets not available in the `if:` condition
* only skip database / pytest step if missing creds
* test_state: augment modify_state test for writing MutableProxy
If the object contains a MutableProxy inside of it, then we get a pickling
error.
* Implement __reduce_ex__ for MutableProxy
Pass through `__reduce_ex__` onto the wrapped instance to strip it off when
cloudpickling to redis.
* base: get_value actually works with a str key
Unless the key isn't a field on the model, then it falls back to the previous
behavior of just returning the given key as is... why does it do this? I don't
know.
* fix image serializing
* If get_format_mimetype does not work, look up format in Image.MIME
Throw a warning if the image format does not have an associated MIME type and
ultimately fallback to image/png and let the browser figure it out.
* test_media: end to end serialization of PIL images
---------
Co-authored-by: Masen Furer <m_github@0x26.net>
* Move sharding internal to StateManager
Avoid leaking sharding implementation details all over the State class and
breaking the API
* WiP StateManager based sharding
* Copy the state __dict__ when serializing to avoid breaking the instance
* State tests need to pass the correct substate token for redis
* state: when getting parent_state, set top_level=False
ensure that we don't end up with a broken tree
* test_app: get tests passing with redis by passing the correct token
refactor upload tests to suck less
* test_client_storage: look up substate key
* state.py: pass static checks
* test_dynamic_routes: working with redis state shard
* Update the remaining AppHarness tests to pass {token}_{state.get_full_name()}
* test_app: pass all tokens with state suffix
* StateManagerRedis: clean up commentary
* feat: Synchronizing localStorage between tabs using browser events
* test_client_storage: Test sync'd local storage vars
* update_vars_internal: generic handler to apply var changes to state tree
Apply fully qualified var names to each substate they are associated with. This
allows consistent updates to arbitrary state vars without having to know their
"setter" arguments, in case the user has overwritted the `set_x` name.
---------
Co-authored-by: Masen Furer <m_github@0x26.net>