Comments (3)
Hi @karnrage
This seems like more of a Dash question than specifically a problem with dash-bootstrap-components. I would recommend asking your question on the Plotly Community Forum instead, as the issue tracker here is really just for reporting bugs and making feature requests.
At first glance though, something that might be worth looking into is the section updates on page load in the Dash docs. It would allow you to update the workbook each time the app was loaded. If your app allows the user to make changes to the underlying file though then you'll probably have to rethink.
LAYOUT = ... # define your layout
WB = None
def reload_workbook_and_return_layout():
with xw.App(visible=True) as app:
global WB
WB = app.books.open(...)
return LAYOUT
app = Dash()
app.layout = reload_workbook_and_return_layout
from dash-bootstrap-components.
Hello,
Then I would like to make this a feature request. A component that would allow passing the file as an id/property pair.
When you say updating the workbook, do you mean as only to write/delete to the workbook? Aren't the workbook and file the same thing? The way we have it the workbook does calculations/evaluations within both VBA and cell formulas.
The 'with' statement handles the closing of the file within itself. Normally this is good, but for our case we want the file to remain open until the final callback is invoked. That's why I wanted a chained callback so I could revert using 'with.' The first would handle the connection, the second would handle the updating/evaluation and closing.
I attempted the global way, but then I lose the multiple instance feature. Our code is a little different so I will attempt what you have. If it works then great, but this is a workaround.
from dash-bootstrap-components.
Then I would like to make this a feature request. A component that would allow passing the file as an id/property pair.
I'm afraid that's not something we're going to support as it's out of scope for this library. The purpose of dash-bootstrap-components is really only to make available Bootstrap features and components more easily available in Dash. What you're requesting is a fairly specialised use-case focused on backend organisation and persistence of data.
Aren't the workbook and file the same thing?
Not necessarily. I don't know much about xlwings, but it's possible you could load the contents of the file in memory, change what you have stored in memory, and simply not persist that back to the file. Multiple users could be referring to a different copy of the data in memory, making changes, without affecting anyone else reading the file.
we want the file to remain open until the final callback is invoked
This is tricky with Dash because callbacks are ideally supposed to be stateless. This is important when running a Dash app with multiple workers, because a single user could have their callbacks processed by different workers which won't have access to the same memory, hence not the same global variables.
There's basically two things you can do:
- Only ever deploy the app with one worker. It will work but might limit your ability to scale the app if you anticipate lots of users.
- Have some kind of shared memory store that holds the open files and can be accessed by each worker using some identifier. The best choice here will be highly dependent on your deployment environment and exactly what you're looking to save.
I attempted the global way, but then I lose the multiple instance feature.
Instead of a single global variable, you could have a dict
storing {identifier: workbook}
. Then when the first callback is initiated, you save the identifier client-side in dcc.Storage
which you pass as State
to all subsequent callbacks. That way each callback could access the open workbook via WORKBOOKS[identifier]
. You'll need to be careful to clean up after yourself though, as you don't want to keep appending to the dict
every single time the callback is run. Ideally your final callback would clean up that entry of the global dict
.
I will emphasis again that my knowledge of this kind of thing is limited, and you'll be better off asking for help on the forum.
from dash-bootstrap-components.
Related Issues (20)
- Support tooltips without IDs HOT 3
- [Bug] Console warning on dbc.Tooltip component HOT 3
- Web site is not showing components HOT 5
- Graphs in tabs example not rendering HOT 2
- Support 'clearable' in Input HOT 1
- Allow not showing up-down arrows in numeric HOT 1
- [BUG] dbc.Modal(style) is passed to fade-modal-show layer instead modal HOT 3
- dbc.TextArea n_submit should not increment for Shift+Enter? HOT 3
- Consider Supporting Hyperlinks in Carousel Images HOT 6
- Dropdown presentation in data table doesn't work HOT 1
- Keyword argument for value OR placeholder HOT 2
- BUG: max doesn't work on nested progress bar HOT 3
- Docs app not working with Dash 2.14.0 HOT 3
- Allow icons and html in `dbc.AccordionItem()` title HOT 3
- Remove migration guide in docs
- selected attribute for dbc.Select HOT 1
- `dbc.Checklist` does not accept `label` as `list[Component]` like `dcc.Checklist` does HOT 3
- dash_bootstrap_components version versus python version HOT 5
- Nested tabs in `Offcanvas` component trigger scroll up event on tab change HOT 2
- Tooltip closing race condition with children change callback HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dash-bootstrap-components.