From 8683356926f0753828832f2977966fe15b160fab Mon Sep 17 00:00:00 2001 From: Alek99 Date: Thu, 26 Jun 2025 12:38:55 -0700 Subject: [PATCH 1/5] Databricks self host --- blog/2025-06-25-reflex-080.md | 159 ++++++++++++++ docs/hosting/databricks.md | 207 ++++++++++++++++++ .../docpage/sidebar/sidebar_items/learn.py | 5 +- 3 files changed, 370 insertions(+), 1 deletion(-) create mode 100644 blog/2025-06-25-reflex-080.md create mode 100644 docs/hosting/databricks.md diff --git a/blog/2025-06-25-reflex-080.md b/blog/2025-06-25-reflex-080.md new file mode 100644 index 0000000000..2d6436dfa3 --- /dev/null +++ b/blog/2025-06-25-reflex-080.md @@ -0,0 +1,159 @@ +--- +author: Alek Petuskey +date: 2025-06-25 +title: "Reflex v0.8.0" +description: "Enhanced performance, cleaner architecture, and improved developer experience in Reflex v0.8.0" +image: /blog/reflex-080.webp +meta: [ + {"name": "keywords", "content": "reflex v0.8.0, python web framework, react router, performance improvements, breaking changes, migration guide"}, +] +--- + +We're excited to announce the release of Reflex 0.8.0, a significant milestone that brings enhanced performance, cleaner architecture, and improved developer experience to our Python web framework. After extensive testing through multiple alpha releases, this version represents one of our most substantial updates yet. + +## The Big Change: From Next.js to React Router + +**Reflex 0.8.0 marks a major architectural transformation** as we migrate from Next.js to React Router as our underlying frontend framework. This fundamental change is the driving force behind all the performance improvements and enhanced developer experience in this release. + +### Why We Made the Switch + +The transition from Next.js to React Router allows us to: + +- **Significantly improve development performance** with faster hot reloads and build times +- **Reduce bundle size** and improve runtime performance for your applications +- **Simplify the development workflow** with more predictable behavior +- **Better align with modern single-page application (SPA) patterns** +- **Reduce complexity** in our framework internals + +### What This Means for Performance + +The React Router migration delivers substantial performance improvements across the board: + +- **Faster Hot Module Replacement (HMR)** - Development reloads are now significantly faster +- **Reduced build times** - Your applications compile and deploy more quickly +- **Optimized routing** - Client-side navigation is smoother and more responsive +- **Smaller bundle sizes** - Your applications load faster for end users +- **Improved memory usage** - Better resource management during development and production + +### Enhanced Developer Experience + +The architectural shift also brings significant developer experience improvements: + +- **More predictable behavior** during development with cleaner state management +- **Simplified deployment** with streamlined build processes +- **Better error handling** and debugging capabilities +- **Cleaner environment variable handling** with proper `REFLEX_` prefixing requirements +- **Improved static file handling** and asset management + +## Breaking Changes and Deprecation Cleanup + +**Important**: Reflex 0.8.0 removes several previously deprecated features. Please review your code before upgrading: + +### Removed Deprecated Features + +- **`UploadFile.filename`** (deprecated in 0.7.1) - Use `UploadFile.name` instead +- **`App.error_boundary`** (deprecated in 0.7.1) - Use `App.app_wraps` +- **`App.api`** (deprecated in 0.7.9) - Use `api_transformer=your_fastapi_app` +- **`App.add_custom_404_page`** (deprecated in 0.6.7) - Use `add_page` with `/404` route +- **Non-prefixed config environment variables** (deprecated in 0.7.13) - Now require `REFLEX_` prefix +- **Various Gunicorn configuration variables** - Use direct Gunicorn environment flags instead + +### Environment Variable Changes + +All Reflex configuration environment variables now require the `REFLEX_` prefix: +```bash +# Old (no longer supported) +ENV_FILE=.env + +# New (required) +REFLEX_ENV_FILE=.env +``` + +## Migration Guide + +The transition from Next.js to React Router is handled automatically by Reflex, but there are some important steps to ensure a smooth upgrade: + +### Automatic Migration + +**Good news**: The Next.js to React Router migration is handled automatically by the framework. Your existing Reflex applications will continue to work without code changes in most cases. + +### Manual Steps Required + +1. **Update your installation:** + ```bash + pip install reflex==0.8.0 + ``` + +2. **Update environment variables** to use the `REFLEX_` prefix: + ```bash + # Old (no longer supported) + ENV_FILE=.env + + # New (required) + REFLEX_ENV_FILE=.env + ``` + +3. **Review deprecated features** in your codebase and update accordingly (see breaking changes above) + +4. **Test your application thoroughly**, paying special attention to: + - **Routing behavior** - navigation between pages + - **File upload functionality** - update any `UploadFile.filename` usage + - **Custom 404 pages** - migrate to the new `add_page` method + - **Environment variable usage** - ensure all use the `REFLEX_` prefix + +5. **Clean rebuild** (recommended): + ```bash + reflex clean + reflex init # if prompted + reflex run + ``` + +### Performance Validation + +After upgrading, you should notice: +- Faster development server startup +- Quicker hot reloads during development +- Improved build times +- More responsive application performance + +## Community Testing and Feedback + +This release benefited greatly from our community's participation in the alpha testing program. Through versions 0.8.0a1 through 0.8.0a4, developers provided valuable feedback that helped us identify and resolve issues before the stable release. + +Special thanks to all community members who participated in testing and reported issues through [our GitHub discussions](https://github.com/orgs/reflex-dev/discussions/5450). + +## Looking Ahead + +Reflex 0.8.0 sets the foundation for exciting future developments. We're continuing to focus on: + +- Enhanced performance optimizations +- Expanded component library +- Better integration with modern web development tools +- Improved documentation and developer resources + +## Get Started Today + +Ready to try Reflex 0.8.0? Here's how to get started: + +```bash +pip install reflex==0.8.0 +reflex init my-app +cd my-app +reflex run +``` + +For detailed documentation, examples, and migration guides, visit our [official documentation](https://reflex.dev/docs). + +## Support and Community + +If you encounter any issues with the upgrade or have questions about new features: + +- Report bugs on our [GitHub repository](https://github.com/reflex-dev/reflex) +- Join discussions in our [community forum](https://github.com/orgs/reflex-dev/discussions) +- Check our documentation for detailed guides and examples + +--- + +Reflex 0.8.0 represents our commitment to making Python web development more accessible, performant, and enjoyable. We're excited to see what you'll build with these new capabilities! + +*The Reflex Team* diff --git a/docs/hosting/databricks.md b/docs/hosting/databricks.md new file mode 100644 index 0000000000..601ac2ed10 --- /dev/null +++ b/docs/hosting/databricks.md @@ -0,0 +1,207 @@ +```python exec +import reflex as rx +from pcweb.styles.styles import get_code_style, cell_style + +``` + +# Deploying Reflex to Databricks + +This guide walks you through deploying a Reflex web application on Databricks using the Apps platform. + +## Prerequisites + +- Databricks workspace with Unity Catalog enabled +- GitHub repository containing your Reflex application +- Reflex Enterprise license (for single-port deployment) + +## Step 1: Connect Your Repository + +1. **Link GitHub Repository** + - Navigate to your Databricks workspace + - Go to your user directory + - Click **Create** → **Git folder** + - Paste the URL of your GitHub repository containing the Reflex application + +## Step 2: Configure Application Settings + +### Create Configuration File + +Create a new file called `app.yaml` directly in Databricks (not in GitHub): + +```yaml +command: [ + "reflex", + "run", + "--env", + "prod", + "--backend-port", + "$DATABRICKS_APP_PORT" +] + +env: + - name: "HOME" + value: "/tmp/reflex" + - name: "REFLEX_ACCESS_TOKEN" + value: "your-token-here" + - name: "DATABRICKS_WAREHOUSE_ID" + valueFrom: "sql_warehouse" + - name: "DATABRICKS_CATALOG" + value: "your-catalog-name" + - name: "DATABRICKS_SCHEMA" + value: "your-schema-name" + - name: "SHOW_BUILT_WITH_REFLEX" + value: 0 +``` + +### Obtain Required Tokens + +1. **Reflex Access Token** + - Visit [Reflex Cloud Tokens](https://cloud.reflex.dev/tokens/) + - Navigate to Account Settings → Tokens + - Create a new token and copy the value + - Replace `your-token-here` in the configuration + +2. **Databricks Resources** + - Update `DATABRICKS_CATALOG` with your target catalog name + - Update `DATABRICKS_SCHEMA` with your target schema name + +## Step 3: Enable Single-Port Deployment + +Update your Reflex application for Databricks compatibility: + +### Update rxconfig.py + +```python +import reflex as rx +import reflex_enterprise as rxe + +rxe.Config(app_name="your-app-name", use_single_port=True) +``` + +### Update Application Entry Point + +Modify your main application file where you define `rx.App`: + +```python +import reflex_enterprise as rxe + +app = rxe.App( + # your app configuration +) +``` + +Also remember to add `reflex-enterprise` to your `requirements.txt` file. + +## Step 4: Create Databricks App + +1. **Navigate to Apps** + - Go to **Compute** → **Apps** + - Click **Create App** + +2. **Configure Application** + - Select **Custom App** + - Configure SQL warehouse for your application + +## Step 5: Set Permissions + +### Catalog Permissions + +1. Navigate to **Catalog** → Select your target catalog +2. Go to **Permissions** +3. Add the app's service principal user +4. Grant the following permissions: + - **USE CATALOG** + - **USE SCHEMA** + +### Schema Permissions + +1. Navigate to the specific schema +2. Go to **Permissions** +3. Grant the following permissions: + - **USE SCHEMA** + - **EXECUTE** + - **SELECT** + - **READ VOLUME** (if required) + +## Step 6: Deploy Application + +1. **Initiate Deployment** + - Click **Deploy** in the Apps interface + - When prompted for the code path, provide your Git folder path or select your repository folder + +2. **Monitor Deployment** + - The deployment process will begin automatically + - Monitor logs for any configuration issues + +## Updating Your Application + +To deploy updates from your GitHub repository: + +1. **Pull Latest Changes** + - In the deployment interface, click **Deployment Source** + - Select **main** branch + - Click **Pull** to fetch the latest changes from GitHub + +2. **Redeploy** + - Click **Deploy** again to apply the updates + +## Configuration Reference + +```python eval +rx.table.root( + rx.table.header( + rx.table.row( + rx.table.column_header_cell("Environment Variable"), + rx.table.column_header_cell("Description"), + rx.table.column_header_cell("Example"), + ), + ), + rx.table.body( + rx.table.row( + rx.table.cell(rx.code("HOME")), + rx.table.cell("Application home directory"), + rx.table.cell(rx.code("/tmp/reflex")), + ), + rx.table.row( + rx.table.cell(rx.code("REFLEX_ACCESS_TOKEN")), + rx.table.cell("Authentication for Reflex Cloud"), + rx.table.cell(rx.code("rx_token_...")), + ), + rx.table.row( + rx.table.cell(rx.code("DATABRICKS_WAREHOUSE_ID")), + rx.table.cell("SQL warehouse identifier"), + rx.table.cell("Auto-assigned"), + ), + rx.table.row( + rx.table.cell(rx.code("DATABRICKS_CATALOG")), + rx.table.cell("Target catalog name"), + rx.table.cell(rx.code("main")), + ), + rx.table.row( + rx.table.cell(rx.code("DATABRICKS_SCHEMA")), + rx.table.cell("Target schema name"), + rx.table.cell(rx.code("default")), + ), + rx.table.row( + rx.table.cell(rx.code("SHOW_BUILT_WITH_REFLEX")), + rx.table.cell("Show Reflex branding (Enterprise only)"), + rx.table.cell([rx.code("0"), " or ", rx.code("1")]), + ), + ), + variant="surface", + margin_y="1em", +) +``` + +## Troubleshooting + +- **Permission Errors**: Verify that all catalog and schema permissions are correctly set +- **Port Issues**: Ensure you're using `$DATABRICKS_APP_PORT` and single-port configuration +- **Token Issues**: Verify your Reflex access token is valid and properly configured +- **Deployment Failures**: Check the deployment logs for specific error messages + +## Notes + +- Single-port deployment requires Reflex Enterprise +- Configuration must be created directly in Databricks, not pushed from GitHub +- Updates require manual pulling from the deployment interface \ No newline at end of file diff --git a/pcweb/components/docpage/sidebar/sidebar_items/learn.py b/pcweb/components/docpage/sidebar/sidebar_items/learn.py index d59b7169e7..7e0c7e9cc7 100644 --- a/pcweb/components/docpage/sidebar/sidebar_items/learn.py +++ b/pcweb/components/docpage/sidebar/sidebar_items/learn.py @@ -239,7 +239,10 @@ def get_sidebar_items_hosting(): create_item("CLI Reference", children=cloud_cliref.pages), create_item( "Self Hosting", - children=[hosting.self_hosting], + children=[ + hosting.self_hosting, + hosting.databricks, + ], ), ] return items From b52d7fc4f74ab6330b2c94c0aae5bb1f1b8bff78 Mon Sep 17 00:00:00 2001 From: Alek99 Date: Thu, 26 Jun 2025 12:45:42 -0700 Subject: [PATCH 2/5] updates --- docs/hosting/databricks.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/hosting/databricks.md b/docs/hosting/databricks.md index 601ac2ed10..c3199737dd 100644 --- a/docs/hosting/databricks.md +++ b/docs/hosting/databricks.md @@ -4,7 +4,7 @@ from pcweb.styles.styles import get_code_style, cell_style ``` -# Deploying Reflex to Databricks +# Deploy Reflex to Databricks This guide walks you through deploying a Reflex web application on Databricks using the Apps platform. @@ -60,7 +60,6 @@ env: - Navigate to Account Settings → Tokens - Create a new token and copy the value - Replace `your-token-here` in the configuration - 2. **Databricks Resources** - Update `DATABRICKS_CATALOG` with your target catalog name - Update `DATABRICKS_SCHEMA` with your target schema name @@ -90,14 +89,15 @@ app = rxe.App( ) ``` -Also remember to add `reflex-enterprise` to your `requirements.txt` file. +```md alert info +# Also add `reflex-enterprise` and `asgiproxy` to your `requirements.txt` file. +``` ## Step 4: Create Databricks App 1. **Navigate to Apps** - Go to **Compute** → **Apps** - Click **Create App** - 2. **Configure Application** - Select **Custom App** - Configure SQL warehouse for your application @@ -128,7 +128,6 @@ Also remember to add `reflex-enterprise` to your `requirements.txt` file. 1. **Initiate Deployment** - Click **Deploy** in the Apps interface - When prompted for the code path, provide your Git folder path or select your repository folder - 2. **Monitor Deployment** - The deployment process will begin automatically - Monitor logs for any configuration issues @@ -141,7 +140,6 @@ To deploy updates from your GitHub repository: - In the deployment interface, click **Deployment Source** - Select **main** branch - Click **Pull** to fetch the latest changes from GitHub - 2. **Redeploy** - Click **Deploy** again to apply the updates From 4a5edb24c6816fae7b4ec363d857e78c46b13fc6 Mon Sep 17 00:00:00 2001 From: Alek99 Date: Thu, 26 Jun 2025 12:46:31 -0700 Subject: [PATCH 3/5] remove extra blog --- blog/2025-06-25-reflex-080.md | 159 ---------------------------------- 1 file changed, 159 deletions(-) delete mode 100644 blog/2025-06-25-reflex-080.md diff --git a/blog/2025-06-25-reflex-080.md b/blog/2025-06-25-reflex-080.md deleted file mode 100644 index 2d6436dfa3..0000000000 --- a/blog/2025-06-25-reflex-080.md +++ /dev/null @@ -1,159 +0,0 @@ ---- -author: Alek Petuskey -date: 2025-06-25 -title: "Reflex v0.8.0" -description: "Enhanced performance, cleaner architecture, and improved developer experience in Reflex v0.8.0" -image: /blog/reflex-080.webp -meta: [ - {"name": "keywords", "content": "reflex v0.8.0, python web framework, react router, performance improvements, breaking changes, migration guide"}, -] ---- - -We're excited to announce the release of Reflex 0.8.0, a significant milestone that brings enhanced performance, cleaner architecture, and improved developer experience to our Python web framework. After extensive testing through multiple alpha releases, this version represents one of our most substantial updates yet. - -## The Big Change: From Next.js to React Router - -**Reflex 0.8.0 marks a major architectural transformation** as we migrate from Next.js to React Router as our underlying frontend framework. This fundamental change is the driving force behind all the performance improvements and enhanced developer experience in this release. - -### Why We Made the Switch - -The transition from Next.js to React Router allows us to: - -- **Significantly improve development performance** with faster hot reloads and build times -- **Reduce bundle size** and improve runtime performance for your applications -- **Simplify the development workflow** with more predictable behavior -- **Better align with modern single-page application (SPA) patterns** -- **Reduce complexity** in our framework internals - -### What This Means for Performance - -The React Router migration delivers substantial performance improvements across the board: - -- **Faster Hot Module Replacement (HMR)** - Development reloads are now significantly faster -- **Reduced build times** - Your applications compile and deploy more quickly -- **Optimized routing** - Client-side navigation is smoother and more responsive -- **Smaller bundle sizes** - Your applications load faster for end users -- **Improved memory usage** - Better resource management during development and production - -### Enhanced Developer Experience - -The architectural shift also brings significant developer experience improvements: - -- **More predictable behavior** during development with cleaner state management -- **Simplified deployment** with streamlined build processes -- **Better error handling** and debugging capabilities -- **Cleaner environment variable handling** with proper `REFLEX_` prefixing requirements -- **Improved static file handling** and asset management - -## Breaking Changes and Deprecation Cleanup - -**Important**: Reflex 0.8.0 removes several previously deprecated features. Please review your code before upgrading: - -### Removed Deprecated Features - -- **`UploadFile.filename`** (deprecated in 0.7.1) - Use `UploadFile.name` instead -- **`App.error_boundary`** (deprecated in 0.7.1) - Use `App.app_wraps` -- **`App.api`** (deprecated in 0.7.9) - Use `api_transformer=your_fastapi_app` -- **`App.add_custom_404_page`** (deprecated in 0.6.7) - Use `add_page` with `/404` route -- **Non-prefixed config environment variables** (deprecated in 0.7.13) - Now require `REFLEX_` prefix -- **Various Gunicorn configuration variables** - Use direct Gunicorn environment flags instead - -### Environment Variable Changes - -All Reflex configuration environment variables now require the `REFLEX_` prefix: -```bash -# Old (no longer supported) -ENV_FILE=.env - -# New (required) -REFLEX_ENV_FILE=.env -``` - -## Migration Guide - -The transition from Next.js to React Router is handled automatically by Reflex, but there are some important steps to ensure a smooth upgrade: - -### Automatic Migration - -**Good news**: The Next.js to React Router migration is handled automatically by the framework. Your existing Reflex applications will continue to work without code changes in most cases. - -### Manual Steps Required - -1. **Update your installation:** - ```bash - pip install reflex==0.8.0 - ``` - -2. **Update environment variables** to use the `REFLEX_` prefix: - ```bash - # Old (no longer supported) - ENV_FILE=.env - - # New (required) - REFLEX_ENV_FILE=.env - ``` - -3. **Review deprecated features** in your codebase and update accordingly (see breaking changes above) - -4. **Test your application thoroughly**, paying special attention to: - - **Routing behavior** - navigation between pages - - **File upload functionality** - update any `UploadFile.filename` usage - - **Custom 404 pages** - migrate to the new `add_page` method - - **Environment variable usage** - ensure all use the `REFLEX_` prefix - -5. **Clean rebuild** (recommended): - ```bash - reflex clean - reflex init # if prompted - reflex run - ``` - -### Performance Validation - -After upgrading, you should notice: -- Faster development server startup -- Quicker hot reloads during development -- Improved build times -- More responsive application performance - -## Community Testing and Feedback - -This release benefited greatly from our community's participation in the alpha testing program. Through versions 0.8.0a1 through 0.8.0a4, developers provided valuable feedback that helped us identify and resolve issues before the stable release. - -Special thanks to all community members who participated in testing and reported issues through [our GitHub discussions](https://github.com/orgs/reflex-dev/discussions/5450). - -## Looking Ahead - -Reflex 0.8.0 sets the foundation for exciting future developments. We're continuing to focus on: - -- Enhanced performance optimizations -- Expanded component library -- Better integration with modern web development tools -- Improved documentation and developer resources - -## Get Started Today - -Ready to try Reflex 0.8.0? Here's how to get started: - -```bash -pip install reflex==0.8.0 -reflex init my-app -cd my-app -reflex run -``` - -For detailed documentation, examples, and migration guides, visit our [official documentation](https://reflex.dev/docs). - -## Support and Community - -If you encounter any issues with the upgrade or have questions about new features: - -- Report bugs on our [GitHub repository](https://github.com/reflex-dev/reflex) -- Join discussions in our [community forum](https://github.com/orgs/reflex-dev/discussions) -- Check our documentation for detailed guides and examples - ---- - -Reflex 0.8.0 represents our commitment to making Python web development more accessible, performant, and enjoyable. We're excited to see what you'll build with these new capabilities! - -*The Reflex Team* From 99f0f4f8fff7d029a540fe376c589833b8c7f25b Mon Sep 17 00:00:00 2001 From: Alek99 Date: Fri, 27 Jun 2025 12:14:21 -0700 Subject: [PATCH 4/5] update --- docs/hosting/databricks.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/hosting/databricks.md b/docs/hosting/databricks.md index c3199737dd..4b51a26d52 100644 --- a/docs/hosting/databricks.md +++ b/docs/hosting/databricks.md @@ -49,7 +49,7 @@ env: value: "your-catalog-name" - name: "DATABRICKS_SCHEMA" value: "your-schema-name" - - name: "SHOW_BUILT_WITH_REFLEX" + - name: "REFLEX_SHOW_BUILT_WITH_REFLEX" value: 0 ``` @@ -74,7 +74,7 @@ Update your Reflex application for Databricks compatibility: import reflex as rx import reflex_enterprise as rxe -rxe.Config(app_name="your-app-name", use_single_port=True) +rxe.Config(app_name="app", use_single_port=True) ``` ### Update Application Entry Point From 3c165b7806f11836070d7db1df2645d54e87057a Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Fri, 27 Jun 2025 12:16:14 -0700 Subject: [PATCH 5/5] Update databricks.md --- docs/hosting/databricks.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/hosting/databricks.md b/docs/hosting/databricks.md index 4b51a26d52..7252a35ab7 100644 --- a/docs/hosting/databricks.md +++ b/docs/hosting/databricks.md @@ -181,7 +181,7 @@ rx.table.root( rx.table.cell(rx.code("default")), ), rx.table.row( - rx.table.cell(rx.code("SHOW_BUILT_WITH_REFLEX")), + rx.table.cell(rx.code("REFLEX_SHOW_BUILT_WITH_REFLEX")), rx.table.cell("Show Reflex branding (Enterprise only)"), rx.table.cell([rx.code("0"), " or ", rx.code("1")]), ), @@ -202,4 +202,4 @@ rx.table.root( - Single-port deployment requires Reflex Enterprise - Configuration must be created directly in Databricks, not pushed from GitHub -- Updates require manual pulling from the deployment interface \ No newline at end of file +- Updates require manual pulling from the deployment interface