Commit Graph

1295 Commits

Author SHA1 Message Date
Martin Xu
5c8d5e5950
remove types-tabulate from dev deps, it is in CLI (#2977) 2024-04-01 15:58:57 -07:00
Martin Xu
8cf1ef6a7d
Revert "[REF-2269] Add add_imports API for component class (#2937)" (#2978)
This reverts commit 8edd1dfdc9.
2024-04-01 15:58:36 -07:00
Masen Furer
5eebe33562
bump to 0.4.6 (#2975) 2024-04-01 12:06:42 -07:00
Nikhil Rao
831be95b39
Relax typer pin (#2976) 2024-04-01 12:06:41 -07:00
Nikhil Rao
3f84191bee
Pin uvicorn and typer versions (#2974) 2024-04-01 11:34:24 -07:00
Martin Xu
30d856efd3
adjust share command prompt (#2965)
* adjust share command prompt

* use lower case "y" for console.ask, keep order consistent as "y" then "n"

* share command update: do not suggest demo URL is mandatory, also move to the last question; when checking if user has permission to upsert package, do POST to record this package (if first time sharing)

* clean up prompt for preview image
2024-04-01 11:33:29 -07:00
Thomas Brandého
0af4770180
generate pyi files when building/publishing 3rd party component (#2945)
* build pyi files when building/publishing 3rd party

* fix typo in workflow

* add future annotation

* add tests to pass coverage check

* add more unit tests

* omit pyi_generator from test coverage

* change black from dev deps to direct deps

* remake all pyi

* format pyi if black is present, return as if otherwise

* fix requested changes

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-03-29 09:54:21 -07:00
Masen Furer
55b0fb36e8
[REF-2219] Avoid refetching states that are already cached (#2953)
* Add test_get_state_from_sibling_not_cached

A better unit test to catch issues with refetching parent states
and calculating the wrong parent state names to fetch.

* _determine_missing_parent_states: correctly generate state names

Prepend only the previous state name to the current relative_parent_state_name
instead of joining all of the previous state names together.

* [REF-2219] Avoid refetching states that are already cached

The already cached states may have unsaved changes which can be wiped out if
they are refetched from redis in the middle of handling an event.

If the root state already knows about one of the potentially missing states,
then use the instance that is already cached.

Fix #2851
2024-03-29 09:42:25 -07:00
Masen Furer
628c865530
Set is_hydrated=False at route onChangeStart (#2949)
* Connection pulser only depends on has_connection_errors

Avoid showing the WiFi error icon when the state is hydrating / navigating
because not being hydrated is not indicative of a connection error in itself.

* Set is_hydrated=False at route onChangeStart

When navigation event starts, set is_hydrated=False on the client side before
any on_load event is dispatched. This avoids a flickering problem where the
client browser navigates and briefly shows content on the page before
processing on_load events associated with the page.

Fix #2885

* Update pyi
2024-03-29 09:41:18 -07:00
Abhivyakt Bhati
ee66884e96
Update README.md (#2963)
Fixed deployment link. The previous one was wrong and led to a 404 error on Reflex's website
2024-03-29 09:28:33 -07:00
Malte Klemm
86526cba51
[REF-2127] Loosen requirements (#2796)
* Remove upper bounds of most dependencies.

Also adds a import try except block for pydantic.v1 and relocks.

Keep black and ruff to not mess to much with current formatting

Make pyright see the right import as long as constraint still lock pydantiv v1

Down pin pytest-asyncio again due to known issue

Fix upload handler with latest versions of fastapi

Change comment

* Add changed lockfile

* Set max versions for deps

* Revert app.pyi

---------

Co-authored-by: Malte Klemm <malte.klemm@blueyonder.com>
Co-authored-by: Nikhil Rao <nikhil@reflex.dev>
2024-03-29 09:26:53 -07:00
Masen Furer
5510eaf820
[REF-2265] ComponentState: scaffold for copying State per Component instance (#2923)
* [REF-2265] ComponentState: scaffold for copying State per Component instance

Define a base ComponentState which can be used to easily create copies of the
given State definition (Vars and EventHandlers) that are tied to a particular
instance of a Component (returned by get_component)

* Define `State` field on `Component` for typing compatibility.

This is an Optional field of Type[State] and is populated by ComponentState.

* Add integration/test_component_state.py

Create two independent counters and increment them separately

* Add unit test for ComponentState
2024-03-29 09:22:25 -07:00
Martin Xu
f372402ee4
[REF-2272] Support declaring EventHandlers directly in component (#2952) 2024-03-29 06:26:07 -07:00
Yummy-Yums
e2eced79b1
Scroll to feature (#2948)
* updated watchdog dep

* added scroll_to feature

* Fix pre-commit and pyi issues

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-03-28 17:18:08 -07:00
Masen Furer
8ef193809c
textarea: expose auto_height and enter_key_submit props (#2884)
* textarea: expose auto_height and enter_key_submit props

These two props improve the workflow for chat apps and other situations where
we want multiline input.

auto_height: resize the textarea based on its contents

enter_key_submit: pressing enter submits the enclosing form (shift+enter
inserts new lines)

Fix #1231

* Update pyi
2024-03-28 17:17:30 -07:00
Martin Xu
68c56a9811
[REF-2168] Add share options to custom component commands (#2883)
* add command to share custom component info for gallery

* cleanup

* tested

* Update custom_components.py

Co-authored-by: Masen Furer <m_github@0x26.net>

* reorder the questions

* ask user to verify info before publishing

* remove questions already captured in pyproject.toml

* no need to cache form inputs since not many questions

* tested

* cleanup

* delete test

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-03-28 15:13:37 -07:00
Masen Furer
c9e87d70df
parse_args_spec: resolve annotations with typing.get_type_hints (#2849)
* parse_args_spec: resolve annotations with typing.get_type_hints

Ensure that event trigger specs in modules with future annotations are resolved
correctly.

Fix #2848

* Fix arg spec for on_upload_progress event

Make py3.8 compatible with `get_type_hints`
2024-03-28 12:16:04 -07:00
Martin Xu
8edd1dfdc9
[REF-2269] Add add_imports API for component class (#2937) 2024-03-28 11:03:26 -07:00
Thomas Brandého
1810288007
remove inheritance from Flex for list components (#2936) 2024-03-28 10:58:36 -07:00
Yummy-Yums
e4ff87326a
updated watchdog dep (#2946) 2024-03-28 09:29:46 -07:00
Masen Furer
03eb258ee7
[REF-2416] Pass shell=True when starting AppHarness on Windows (#2944)
In exec.py, run_process_and_launch_url already passes `shell=True` on windows,
but the AppHarness has never really been used on Windows, so we were missing
this detail.

Fix #2941
2024-03-27 16:22:58 -07:00
Masen Furer
b23859a45d
[REF-2302] When a Var points to a model, prefer access to model fields. (#2893)
* When a Var points to a model, prefer access to model fields.

When a Var points to a model, and fields of the model share the same name as
Var operations, access to the model fields is now preferred to avoid having Var
operation names shadow model fields. Since most Var operations do not actually
work against Models, this does not really block any functionality.

* Special case for ComputedVar needing to internally access fget

Since fget is a "slot" on property, normal __getattribute__ access cannot find it.

* Workaround https://github.com/python/cpython/issues/88459

In python 3.9 and 3.10, the `isinstance(list[...], type)` returns True, but
it's not a valid class for use in issubclass
2024-03-27 16:22:46 -07:00
Masen Furer
b788890696
[REF-2089] Use dill instead of cloudpickle for serialization (#2922)
* Use dill instead of cloudpickle for serialization

* smaller size pickles
* support dynamically defined states
* avoid issues with unpickleable globals

* pyproject: add dill, remove cloudpickle

* poetry.lock: relock dependencies

* Dynamically convert EventHandler to functools.partial

Instead of converting the functions up front and assigning them to the
instance, unbox the function from the EventHandler when it is requested via
__getattribute__. This reduces the size of the per-instance pickle, because
event handler bodies do not need to be included.

* Improve checking for cython_function_or_method

Because pydantic can be installed without cython, only use the workaround in
the case where the BaseModel.validate function is NOT a FunctionType,
indicating it's a cython function.

* Serialize all State subclasses by reference
2024-03-27 13:47:33 -07:00
Elijah Ahianyo
b34c97d725
Default to None if bun/fnm version is Invalid (#2940) 2024-03-27 12:38:56 -07:00
Thomas Brandého
94823f1317
fix hook order to use ref inside user hooks (#2906)
* fix hook order to use ref inside user hooks

* 2nd attempt to fix ref_hook order

* add missing definition

* remove print statements
2024-03-27 12:49:11 +01:00
Masen Furer
012151132e
Remove page.pyi: it's out of date, and not necessary (#2924)
Fix #2908
2024-03-26 20:21:29 +01:00
benedikt-bartscher
f27eae7655
fix AppHarness reloading (#2916)
* move AppHarness tests to module scope

* fix AppHarness reloading

* add test

* docstrings and formatting

* fix benchmarks not reloading state module
2024-03-26 11:09:46 -07:00
Elijah Ahianyo
61c6728006
[REF-2229]Dedupe deprecation warnings (#2871)
* Dedupe deprecation warnings

* Update reflex/utils/console.py

Co-authored-by: Masen Furer <m_github@0x26.net>

* address PR comments

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-03-26 16:33:55 +00:00
wassaf shahzad
15dc7f4552
added feature to automatically change port (#2867) 2024-03-25 17:38:28 -07:00
Elijah Ahianyo
8a2b92f2e9
[REF-2117]:rx.color_mode_cond to work in f-strings (#2775) 2024-03-25 17:31:53 -07:00
Lucca Psaila
fbc6e7eba3
Update LUCIDE_ICON_LIST with newest Icon names (#2891) 2024-03-25 15:23:10 -07:00
Thomas Brandého
f19a6a8c8d
use radix box instead of chakra one for responsive elements (#2921) 2024-03-25 15:16:48 -07:00
Elijah Ahianyo
e0fedeb419
[REF-1682][REF-1683][REF-1684][REF-2283]Benchmark reflex package size and .web folder (#2880)
* remove codspeed.yml

* test upload job

* minor edits to get upload job working

* perhaps this works

* upload needs relex-install-size

* retrigger pipeline

* test only on ubuntu

* change to save to db directly

* oops

* size benchmarks

* .web for counter

* its timeout-minutes

* se integration.sh to run and kill process

* install psycopg2

* move .web runs to integration_tests.yml to save runners

* fix measurement-type for reflex-web

* add database url to env

* psycopg2

* test run ids

* commit sha gets the job done

* refactor

* add more matrices

* move reflex package size to integration_test.yml

* fix venv path

* test fix

* test fix

* use hyphen

* testing reflex build size

* ls for temp debug

* fix typo in command

* possible fix

* possible fix for windows

* remove dead code

* remove dead code

* remove unwanted comments

* refactor

* rebase on main

* pr_title

* remove pr_title from args

* debug

* should work now

* precommit fix

* print out package size for

* add shell

* test

* trying again

* dont use cached poetry to have accurate measurement of deps

* remove reflex deps calculation step from integration job

* fix script path

* precommit fix

* no real difference on different python versions so use 3.11.5

* remove ls keyword
2024-03-25 08:33:28 +00:00
Nikhil Rao
c3f364268b
Revert "add precommit check added large files and git lfs rules (#2866)" (#2905)
This reverts commit 8a8fc76fc4.
2024-03-23 00:37:11 -07:00
Martin Xu
1e3e1dfe17
include twine in dependencies on pyproject.toml instead of installing on fly (#2895) 2024-03-21 12:48:41 -07:00
Elijah Ahianyo
83318530f2
[REF-2284]Benchmark add extra info on publishing data (#2864)
* Benchmark add extra info on publishing data

* fix typo

* get file name for simplicity

* precommit fix

* removesuffix not in python3.8

* add pr_id in case the pr title is changed

* precommit fix
2024-03-21 07:25:40 +00:00
Masen Furer
58f706ac7a
[REF-1982] state: Warn if redis state is "too big" (#2868)
If the state serializes to over 100kb and has substates, then print a warning
suggesting the developer reduce the size of the state.
2024-03-20 16:50:48 -07:00
Martin Xu
f80d7978d2
make PR title optional since push event or PR merge will not have the title (#2889) 2024-03-20 16:38:09 -07:00
Masen Furer
f39c138bfa
bump to 0.4.5 (#2888) 2024-03-20 11:38:19 -07:00
Martin Xu
fa99407b81
Handle quote marks ' " in PR titles in benchmark CI (#2877)
* escape double quote marks in PR title

* move the pr title into the env
2024-03-20 11:30:47 -07:00
Masen Furer
6a071a27e2
vars: set _was_touched when updating cached vars (#2886)
Ensure that updated cached vars are persisted into redis.
2024-03-20 09:50:42 -07:00
Thomas Brandého
1a66e145b5
make list namespace to follow convention of other comps (#2879) 2024-03-19 18:16:54 -07:00
Thomas Brandého
8a8fc76fc4
add precommit check added large files and git lfs rules (#2866) 2024-03-19 18:14:55 -07:00
Masen Furer
7debd3dbb9
When __REFLEX_SKIP_COMPILE == "yes" allow telemetry to fail (#2881)
* When __REFLEX_SKIP_COMPILE == "yes" allow telemetry to fail

Allow running `--backend-only` without a .web directory

* When re-initializing a pre-project_hash project, do not blow up on KeyError
2024-03-19 14:30:55 -07:00
Masen Furer
f446d063fb
HighLevelSelect: pass flex_shrink prop to SelectTrigger (#2876)
* Revert "Remove width prop from rx.select (#2835)"

This reverts commit d14292dc9b.

* HighLevelSelect: pass flex_shrink prop to SelectTrigger

This allows the high level select to have width="100%" and also shrink-to-fit inside a parent container.

Fix #2824, kind of
2024-03-18 15:49:15 -07:00
Masen Furer
ee1ff7f93f
[REF-2122] Opt-in multiprocess compile (#2838)
* Revert "Revert "Revert "Revert "use process pool to compile faster (#2377)" (#2434)" (#2497)" (#2595)"

This reverts commit 6b6eea4d7d.

* Adjust number of operations for more correct progress bar

* app: recognize REFLEX_COMPILE_PROCESSES and REFLEX_COMPILE_THREADS

Control whether multiprocessing is used and the number of processes or threads
that should be used.

This will allow users to opt-in to the new, potentially hazardous,
multiprocessing mode, which results in much faster compiles, but has already
been reverted 4 times. Lets leave the code in this time, but use the thread
pool executor by default.

Limiting the number of threads or processes to 1 can also aid in debugging
issues that arise during compile time.

* Allow REFLEX_COMPILE_PROCESSES=0 to trigger multiprocessing with auto workers
2024-03-15 17:29:52 -07:00
Masen Furer
b89a18f632
Separate get_hooks and get_hooks_internal for stable output (#2710)
* Separate `get_hooks` and `get_hooks_internal` for stable output

When downstream component wrappers depend on State when writing hooks, they
need to be assured that all internal hooks (events, var hooks, memoized
handlers, etc) will be rendered prior to user-defined hooks.

This also makes it less likely for downstream components to feel the need to
overwrite `get_hooks` (no underscore) directly and break internal functioning
of Reflex components.

* Include internal hooks in AppWrap and Page

* Apply get_hooks_internal in a few more places
2024-03-15 16:16:09 -07:00
Masen Furer
479b5182aa
[REF-2216] Warn if windows is used with py312 (#2856)
Display a warning message, recommending python 3.11 with the current release of
reflex.

We need this until running with a uvicorn version that has better support for
py3.12 on windows.
2024-03-15 11:16:20 -07:00
Thomas Brandého
1048f86dd3
convert text inside list_item to span and set icon display to inline (#2860)
* convert text inside list_item to span and set icon display to inline

* fix props

* add comment for reflex-web
2024-03-15 10:57:20 -07:00
Masen Furer
432fcd4a5b
Account for imports of @rx.memo components for frontend package installation (#2863)
* CustomComponent ignores the annotation type in favor of the passed value

Do not require rx.memo wrapped functions to have 100% correct annotations.

* test_custom_component_get_imports: test imports from wrapped custom components

* Account for imports of custom components for frontend installation

Create new ImportVar that only install the package to avoid rendering the
imports in the page that contains the custom component itself.

* Handle Imports that should never be installed

* Fix up double negative logic

* Perf Optimization: use the imports we already calculate during compile

Instead of augmenting _get_imports with a weird, slow, recursive crawl and
dictionary reconstruction, just use the imports that we compile into the
components.js file to install frontend packages needed by the custom
components.

Same effect, but adds essentially zero overhead to the compilation.
2024-03-15 09:59:59 -07:00