Skip to content
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

Adding a webApp example using Dash #1497

Merged
merged 7 commits into from
Dec 14, 2022
Merged

Adding a webApp example using Dash #1497

merged 7 commits into from
Dec 14, 2022

Conversation

rs-bh-n
Copy link
Contributor

@rs-bh-n rs-bh-n commented Sep 16, 2022

Added a Webapp example for Dash with PyMapdl : 1 file ,1 "assets" folder with four files and a README.txt

@rs-bh-n rs-bh-n added the Examples Publishing PyMAPDL examples label Sep 16, 2022
@github-actions github-actions bot added the Documentation Documentation related (improving, adding, etc) label Sep 16, 2022
@codecov
Copy link

codecov bot commented Sep 16, 2022

Codecov Report

Merging #1497 (f364b24) into main (70c6b3b) will decrease coverage by 4.00%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #1497      +/-   ##
==========================================
- Coverage   85.18%   81.17%   -4.01%     
==========================================
  Files          45       45              
  Lines        7511     7506       -5     
==========================================
- Hits         6398     6093     -305     
- Misses       1113     1413     +300     

@akaszynski
Copy link
Collaborator

@germa89, leaving this for you to review.

We can also consider a separate repo for this.

@germa89
Copy link
Collaborator

germa89 commented Sep 22, 2022

Hi @rs-bh-n

Thank you for this contribution.

I did have a look at the example.

image

And I couldn't make it work, terminal was complaining about:


[2022-09-21 16:35:14,305] ERROR in app: Exception on /_dash-update-component [POST]
Traceback (most recent call last):
  File "C:\ProgramData\Miniconda3\envs\pymapdl_0\lib\site-packages\flask\app.py", line 2525, in wsgi_app
    response = self.full_dispatch_request()
  File "C:\ProgramData\Miniconda3\envs\pymapdl_0\lib\site-packages\flask\app.py", line 1822, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\ProgramData\Miniconda3\envs\pymapdl_0\lib\site-packages\flask\app.py", line 1820, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\ProgramData\Miniconda3\envs\pymapdl_0\lib\site-packages\flask\app.py", line 1796, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "C:\ProgramData\Miniconda3\envs\pymapdl_0\lib\site-packages\dash\dash.py", line 1259, in dispatch
    ctx.run(
  File "C:\ProgramData\Miniconda3\envs\pymapdl_0\lib\site-packages\dash\_callback.py", line 439, in add_context
    output_value = func(*func_args, **func_kwargs)  # %% callback invoked %%
  File "C:\Users\gayuso\Others_pymapdls\pymapdl_0\pymapdl\examples\07-webapps\dash-vm35\BimetallicStrip.py", line 571, in start_pymapdl
    p_run = pyMapdl_vm35(float(L), float(t), float(tr), float(ta), float(e1), float(e2), float(c1), float(c2))
  File "C:\Users\gayuso\Others_pymapdls\pymapdl_0\pymapdl\examples\07-webapps\dash-vm35\BimetallicStrip.py", line 77, in pyMapdl_vm35
    with open(data_file, 'a', newline='\n') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\gayuso\\Others_pymapdls\\pymapdl_0\\pymapdl\\assets\\data.csv'
127.0.0.1 - - [21/Sep/2022 16:35:14] "POST /_dash-update-component HTTP/1.1" 500 -

I think you are not referencing correctly the location of data.csv:

FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\gayuso\\Others_pymapdls\\pymapdl_0\\pymapdl\\assets\\data.csv'

In the meantime, I'm thinking what to do with this example. Because it is mean to have a running MAPDL (docker image probably) on the background to perform the calculations.
I don't think we have that capability in the current documentation implementation, and that suppose a cost (keeping the MAPDL running) and a complication (because of the required infrastructure).

I'm a bit short of manpower at the moment, so I cannot spend as much time as I would like on this. So I would say to create its own repository, so we can make it installable, and someone can run it locally easily. We can upload images of the websites, even gifs, .... I will reference it in the PyMAPDL documentation website.

I think this is a good compromise between complexity and available time. What do you think @rs-bh-n ??

@rs-bh-n
Copy link
Contributor Author

rs-bh-n commented Sep 23, 2022

Hi @germa89 ,
Thanks for checking .

  1. The py file expects the assets folder in the same directory (as the py file) .
    a) Can you check with the assets folder in place?
    b) Should the files (py_file and assets_folder) be zipped to avoid this confusion ?

  2. I did not intend to run a webapp on our server that anybody can access anytime , I understand the complications .
    This example is just a simple demonstration of :
    - how pymapdl can be used as a backend (for a webapp created by user with dash as front end) and
    - how to launch the webapp and interact with backend server (this uses his/her local mapdl installation )

The users can later, with their IT team's help, probably explore webApp deployment(which is out of scope for us) for his/her team. What do you say , @germa89 ?

@germa89 germa89 marked this pull request as draft September 23, 2022 07:50
@germa89
Copy link
Collaborator

germa89 commented Dec 14, 2022

I'm moving this to the example repo: https://github.com/pyansys/pymapdl-examples

@germa89 germa89 closed this Dec 14, 2022
@germa89
Copy link
Collaborator

germa89 commented Dec 14, 2022

Actually no... in that repo there is no general examples. Keeping it here.

@germa89 germa89 reopened this Dec 14, 2022
@germa89 germa89 marked this pull request as ready for review December 14, 2022 12:04
@germa89
Copy link
Collaborator

germa89 commented Dec 14, 2022

@rs-bh-n please have a look of the new proposal.

@germa89 germa89 merged commit 54639d2 into main Dec 14, 2022
@germa89 germa89 deleted the Add_Dash_Example branch December 14, 2022 16:16
@germa89
Copy link
Collaborator

germa89 commented Dec 14, 2022

Merging. Comments or feedback will be added on a later PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Documentation related (improving, adding, etc) Examples Publishing PyMAPDL examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants