-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make scipy
an optional dependency
#2062
Comments
One other thing that comes to mind is we may want to add it to the
That is effectively what this block achieves, albeit in a bit of a dirty way. Lines 41 to 48 in 3f087b5
But yeah MC basically comments that out for the validation API. So the question to me is if scipy can be moved inside this block. It was moved up I think because of that trimesh issue actually, because the other 3 things that you point out should not be needed for validation. Well actually I think we have a validator for custom data that checks that the data the user has provided can be interpolated (e.g. has no repeated coords), so it may be needed for that too. |
Not really sure what the minimum requirements for MC are but autograd depends on scipy (as does xarray as @tylerflex pointed out). That seems pretty tricky to get around? |
yea it does, i wonder if we just need to say that we only validate the |
I would like to share some background about the problem. We use Web Assembly (More specifically, Pyodide) to import Tidy3D so that we can implement some features, like plot source_time, script objects, show grid, plot permittivity and so on. If we can't limit the core dependencies of Tidy3D, the front-end webpage will suffer from crashing because of out-of-memory issues. For now, @majinge7846 accomplished lots of work to remove Scipy for front-end Tidy3D utilization. However, the problem becomes critical when upgrading Tidy3d to v2.7.6. Recently, we want to improve the user experience for frequently used functions (Validate/Estimate). We plan to use the same technical solution to implement it. However, we are facing the same problem. Refer to this. Currently, we use lambda to do validation/estimation and pipeline as backup, which will spend lots of time wasted during the simulation.json file transmission. Instead, if we use web assembly to implement validation/estimation, users can get the results immediately. |
https://github.com/pydata/xarray/blob/9b632fd36edba7c6fcd1eea778ba3d8710c68349/pyproject.toml#L36 scipy is an optional deependency of xarray. And I found that it just used for interpolate(scipy.interpolate.interp1d). webgui can even do a check, if tidy3d wasm error/log validation error, "lack scipy please install first" , this is acceptable, we can use lambda/pipeline as fallback. (Of course, it would be better if numpy or other methods can be used to avoid calling Scipy) I think webgui validation not need designed to handle all simulation cases, just most simulation cases are OK too. lightweight base package may not be needed. |
oh nevermind, scipy is optional in autograd too. i guess that's good news then. what would be the best way to go here? sounds to me like it would make sense to add something like a |
Just catching up on this. Ultimately, this is one of the package refactor aspects we want to implement in 3.0. In the sense that we want to have an This kind of leads to the issue of how to approach this right now (edit to be clear 3.0 is a bit far away still). Unfortunately poetry does not enable us to "minimize" the base package If the pipeline can be a good fallback for all the other non-web-assembly local validation cases then I think this could be a good way to get it to work before 3.0! We'd just have to check the scipy to be sure they are on-the-fly per-function like Tyler mentioned. Happy to do a PR for this if this is the approach we want to go for. |
So my thoughts:
|
Nice, yeah I agree! How urgent is this out of curiosity? If it is very urgent for the web UI (sounds a bit?), probably someone else should do this given my current limited timing constraints. Otherwise, think I've got a few ideas how to implement and properly test this with the right environments as you suggest and happy to focus on cracking on this. Or happy to propose a few implementation approaches too as need be. |
test for web to usage: |
Motivation: allow a more lightweight base package for validation
Not sure if it's possible:
SimulationData.to_mat
) so lazy import should be fine there.Either way, we probably want regular
pip install tidy3d
users to have scipy andinterp()
support. So not sure if to accomplish this goal of having a "lightweight" tidy3d package if we just need to create a more custom installation script to MC rather than usingpyproject.toml
?Thoughts @daquintero @yaugenst @momchil-flex ?
The text was updated successfully, but these errors were encountered: