Commit Graph

1269 Commits

Author SHA1 Message Date
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
Masen Furer
fb2c3606d9
Get client_ip from asgi.scope (#2808)
* Get `client_ip` from `asgi.scope`

It seems like REMOTE_ADDR is always 127.0.0.1, which is not super useful when
trying to figure out where the websocket connection is originating from.

Of course this isn't a silver bullet because most-likely the WS will be passed
through a reverse proxy anyway... in that case, the client IP is likely in the
headers under `x_forwarded_for`

* client_ip: fallback to REMOTE_ADDR
2024-03-14 10:03:30 -07:00
Masen Furer
e3db9adc70
Fix py3.8 integration test_var_operations.py (#2858)
A newly added test was not py3.8 compatible and is breaking CI runs
2024-03-13 17:45:27 -07:00
Elijah Ahianyo
a06b570e3a
Benchmark with app harness (#2774) 2024-03-13 15:59:55 -07:00
Emmanuel Onwuegbusi
2a8d9d1ef4
added name of Var to error message (#2827) 2024-03-13 15:39:49 -07:00
benedikt-bartscher
5701a72c8f
Bare sqlalchemy metadata (#2355) 2024-03-13 15:32:35 -07:00
Masen Furer
036afa951a
Make @rx.memo work with state vars passed as props (#2810)
* Make @rx.memo work with state vars passed as props

Seems like this was a regression from the StatefulComponent refactor, because
trying to pass a state Var to a CustomComponent gave undefined, likely due to
`_get_vars` not accounting for `self.props` in CustomComponents.

With this change, it works.

Integration test added to `test_var_operations.py`

* Allow CustomComponent props to be Component

Avoid calling `.json()` on all Base types because the Var serializer already
does that, but this way, more specific types (like Component) can be serialized
differently.

When the type is Component, attach a VarData with the imports and hooks to when
the Var is rendered, it also carries the correct imports/hooks and does not
throw frontend errors.
2024-03-13 13:41:17 -07:00
Alek Petuskey
4c10cbc6d1
Custom Component Request Template (#2853)
Co-authored-by: Alek Petuskey <alekpetuskey@aleks-mbp.lan>
2024-03-13 12:55:09 -07:00
Thomas Brandého
92db402539
telemetry refactor + unit tests (#2786) 2024-03-13 12:38:54 -07:00
Masen Furer
f52ff56440
[REF-2086] Avoid "Warning: The path to the Node binary could not be found. (#2803) 2024-03-13 12:35:43 -07:00
Nikhil Rao
d14292dc9b
Remove width prop from rx.select (#2835) 2024-03-13 12:32:12 -07:00
Thomas Brandého
e5fc5f9a83
better default title for seo (also remove default description) (#2844)
* better default title for seo (also remove default description)
2024-03-13 11:18:54 -07:00
Masen Furer
eb18ce90d5
[REF-2172] Add DECORATED_PAGES before compiling in thread (#2841) 2024-03-12 10:28:37 -07:00
Masen Furer
7b43b923b8
bump to 0.4.4 (#2833) 2024-03-11 13:00:13 -07:00
Masen Furer
94e750a5f1
[REF-2157] Allow rx.download to resolve rx.get_upload_url links (#2813) 2024-03-11 12:29:34 -07:00
hjpr
4413cb4038
Allow access to position from HighLevelSelect (#2829) 2024-03-11 12:27:38 -07:00
benedikt-bartscher
8a3c9383fb
improve event handler state references (#2818) 2024-03-11 12:18:18 -07:00
Masen Furer
c809107d09
[REF-2158] Enable state when on_load or event_triggers are set. (#2815)
* [REF-2158] Enable state when `on_load` or event_triggers are set.

Basically all events in a reflex app require the backend to be up, even the
built-in server side events round trip to the backend and require "state" even
if no user-defined state classes are declared.

test_app_state_determination: checking that state is enabled at the right time

* Clear out DECORATED_PAGES when initializing a new app
2024-03-08 17:34:09 -08:00
Martin Xu
bf297e2f5b
[REF-2141] Custom component command improvements (#2807)
* add custom component command improvements

* fix test

* fix regex to include both single/double quotes
2024-03-07 20:42:22 -08:00
benedikt-bartscher
f5b7eca9c7
add support for sqlalchemy AssociationProxys (#2809)
* add support for sqlalchemy AssociationProxys

* python 3.8 compatibility
2024-03-07 15:19:35 -08:00
benedikt-bartscher
19a5cdd408
Track state usage (#2441)
* rebase

* pass include_children kwarg in radix FormRoot

* respect include_children

* ruff fixes

* readd statemanager init, run pyi gen

* minor performance imporovements, fix for state changes

* fix pyi and pyright

* pass include_children for chakra

* remove old state detection

* add test for unused states in stateless app

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-03-07 14:25:55 -08:00
Masen Furer
5d647a498f
[REF-1368] Move common form functionality to rx.el.forms (#2801)
* [REF-1368] Move common form functionality to rx.el.forms

Allow plain HTML Form element to have magic on_submit event handler.

* Chakra and Radix forms inherit `on_submit` functionality from rx.el.form

Consolidate logic in the basic HTML form and use it in both Radix and Chakra
form wrappers.

* from __future__ import annotations for py38
2024-03-07 13:17:54 -08:00
benedikt-bartscher
8903ebb8b0
add webdriver option arguments via env (#2783)
* add webdriver option arguments via env

* forgot to split the args
2024-03-06 17:13:40 -08:00
Masen Furer
ecb4dbaea9
[REF-2098] Allow overlay Close components to have on_click handlers (#2793)
* [REF-2098] Allow overlay Close components to have on_click handlers

The child of the Radix *Close components are passed `asChild`, meaning they are
treated as the direct child of the Close itself. This causes the `on_click`
handler attached to such an element to override the default `on_click` behavior
of the Close, which is to close the overlay, thus breaking the desired behavior
of the Close component.

When creating a Close component, if the child has an `on_click` handler, then
internally wrap it in a `Flex` so that the `Flex` gets the `asChild` treatment,
and both the default on_click and the child's on_click are both fired.

Bonus fix: pass `asChild` when constructing the `DrawerClose` to avoid a
<button> in <button> warning in the browser console, because the Drawer does
NOT pass `asChild` to the Close by default.

* Move Trigger logic to RadixThemesTriggerComponent base class

Apply trigger logic to Trigger, Close, Cancel, and Accept components; including
hover_card and dropdown_menu.
2024-03-06 17:09:46 -08:00
Nikhil Rao
c61419a761
Unwrap images in rx.markdown (#2789) 2024-03-06 16:03:33 -08:00
Masen Furer
77d551f781
[REF-1994] ThemePanel: clear chakra-ui-color-mode key when using theme panel (#2799)
The ThemePanel fights with the ThemeProvider when the user color preference key differs from the `appearance` prop specified in the theme. To avoid issues when using the ThemePanel (in development), clear out the user color preference before loading the page and before unloading the page (to ensure it does not freeze on reload).

Clearing the user preference isn't ideal production behavior, but typically the
ThemePanel is only used during development for trying out different styles, and
having it not freeze the app is better dev behavior.

Fix #2650
2024-03-06 15:32:08 -08:00
Masen Furer
03aa28320a
Perf improvements (part 1) (#2779)
* types: remove runtime imports from `is_generic_alias`

Reduce try/except contexts for better performance.

* _decode_var optimizations:

* compile the regex once at module scope
* fast path string scan for REFLEX_VAR_OPENING_TAG before doing more complex logic

* Avoid repeated `hasattr` check in `is_union`

`is_union` gets called a lot, and the hasattr check can be resolved at import
time for better performance.
2024-03-06 10:42:20 -08:00