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

feat: Integrate gRPC based File Transfer Service #2583

Merged
merged 82 commits into from
Apr 17, 2024

Conversation

hpohekar
Copy link
Collaborator

@hpohekar hpohekar commented Mar 18, 2024

closes #2575 #2619

Added file_exists_on_remote method on session level.

Integrate gRPC based File Transfer Service.

We upload the file to pyfluent.EXAMPLES_PATH and pyfluent.EXAMPLES_PATH is mounted on "/mnt/pyfluent"

Therefore Fluent reads from "/mnt/pyfluent/mixing_elbow.msh.h5"

hpohekar@AAPQ13pUvWxQtxN:/mnt/c/Users/hpohekar/pyfluent$ python3.10
Python 3.10.11 (main, Mar 20 2024, 11:19:11) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ansys.fluent.core import launch_fluent
>>> solver = launch_fluent()
[2024-04-01 15:32:26.900043] [0x0000000000c87500] [info]    File transfer server started.
>>> solver.file.read_case(file_name="mixing_elbow.msh.h5")
pyfluent.settings_api WARNING: Mismatch between generated file and server object info. Dynamically created settings classes will be used.
[2024-04-01 15:37:21.161900] [0x00007fa0627fc640] [info]    Initializing upload of file:mixing_elbow.msh.h5
  file size: 2827344
  SHA1 checksum: 84b9081448adeed8acc2784529e6d3ab51d437b7
[2024-04-01 15:37:21.165059] [0x00007fa0627fc640] [debug]   Received 65536 of 2827344 bytes.
[2024-04-01 15:37:21.166214] [0x00007fa0627fc640] [debug]   Received 131072 of 2827344 bytes.
[2024-04-01 15:37:21.167409] [0x00007fa0627fc640] [debug]   Received 196608 of 2827344 bytes.
[2024-04-01 15:37:21.169214] [0x00007fa0627fc640] [debug]   Received 262144 of 2827344 bytes.
[2024-04-01 15:37:21.170644] [0x00007fa0627fc640] [debug]   Received 327680 of 2827344 bytes.
[2024-04-01 15:37:21.171910] [0x00007fa0627fc640] [debug]   Received 393216 of 2827344 bytes.
[2024-04-01 15:37:21.173625] [0x00007fa0627fc640] [debug]   Received 458752 of 2827344 bytes.
[2024-04-01 15:37:21.174487] [0x00007fa0627fc640] [debug]   Received 524288 of 2827344 bytes.
[2024-04-01 15:37:21.176097] [0x00007fa0627fc640] [debug]   Received 589824 of 2827344 bytes.
[2024-04-01 15:37:21.177730] [0x00007fa0627fc640] [debug]   Received 655360 of 2827344 bytes.
[2024-04-01 15:37:21.178831] [0x00007fa0627fc640] [debug]   Received 720896 of 2827344 bytes.
[2024-04-01 15:37:21.179992] [0x00007fa0627fc640] [debug]   Received 786432 of 2827344 bytes.
[2024-04-01 15:37:21.181496] [0x00007fa0627fc640] [debug]   Received 851968 of 2827344 bytes.
[2024-04-01 15:37:21.182677] [0x00007fa0627fc640] [debug]   Received 917504 of 2827344 bytes.
[2024-04-01 15:37:21.184202] [0x00007fa0627fc640] [debug]   Received 983040 of 2827344 bytes.
[2024-04-01 15:37:21.185359] [0x00007fa0627fc640] [debug]   Received 1048576 of 2827344 bytes.
[2024-04-01 15:37:21.187370] [0x00007fa0627fc640] [debug]   Received 1114112 of 2827344 bytes.
[2024-04-01 15:37:21.189106] [0x00007fa0627fc640] [debug]   Received 1179648 of 2827344 bytes.
[2024-04-01 15:37:21.189660] [0x00007fa0627fc640] [debug]   Received 1245184 of 2827344 bytes.
[2024-04-01 15:37:21.191249] [0x00007fa0627fc640] [debug]   Received 1310720 of 2827344 bytes.
[2024-04-01 15:37:21.192800] [0x00007fa0627fc640] [debug]   Received 1376256 of 2827344 bytes.
[2024-04-01 15:37:21.193875] [0x00007fa0627fc640] [debug]   Received 1441792 of 2827344 bytes.
[2024-04-01 15:37:21.195022] [0x00007fa0627fc640] [debug]   Received 1507328 of 2827344 bytes.
[2024-04-01 15:37:21.196400] [0x00007fa0627fc640] [debug]   Received 1572864 of 2827344 bytes.
[2024-04-01 15:37:21.197902] [0x00007fa0627fc640] [debug]   Received 1638400 of 2827344 bytes.
[2024-04-01 15:37:21.199211] [0x00007fa0627fc640] [debug]   Received 1703936 of 2827344 bytes.
[2024-04-01 15:37:21.200264] [0x00007fa0627fc640] [debug]   Received 1769472 of 2827344 bytes.
[2024-04-01 15:37:21.202037] [0x00007fa0627fc640] [debug]   Received 1835008 of 2827344 bytes.
[2024-04-01 15:37:21.203208] [0x00007fa0627fc640] [debug]   Received 1900544 of 2827344 bytes.
[2024-04-01 15:37:21.204463] [0x00007fa0627fc640] [debug]   Received 1966080 of 2827344 bytes.
[2024-04-01 15:37:21.205650] [0x00007fa0627fc640] [debug]   Received 2031616 of 2827344 bytes.
[2024-04-01 15:37:21.207309] [0x00007fa0627fc640] [debug]   Received 2097152 of 2827344 bytes.
[2024-04-01 15:37:21.208817] [0x00007fa0627fc640] [debug]   Received 2162688 of 2827344 bytes.
[2024-04-01 15:37:21.209894] [0x00007fa0627fc640] [debug]   Received 2228224 of 2827344 bytes.
[2024-04-01 15:37:21.211662] [0x00007fa0627fc640] [debug]   Received 2293760 of 2827344 bytes.
[2024-04-01 15:37:21.213099] [0x00007fa0627fc640] [debug]   Received 2359296 of 2827344 bytes.
[2024-04-01 15:37:21.214423] [0x00007fa0627fc640] [debug]   Received 2424832 of 2827344 bytes.
[2024-04-01 15:37:21.215929] [0x00007fa0627fc640] [debug]   Received 2490368 of 2827344 bytes.
[2024-04-01 15:37:21.216981] [0x00007fa0627fc640] [debug]   Received 2555904 of 2827344 bytes.
[2024-04-01 15:37:21.218410] [0x00007fa0627fc640] [debug]   Received 2621440 of 2827344 bytes.
[2024-04-01 15:37:21.219344] [0x00007fa0627fc640] [debug]   Received 2686976 of 2827344 bytes.
[2024-04-01 15:37:21.220877] [0x00007fa0627fc640] [debug]   Received 2752512 of 2827344 bytes.
[2024-04-01 15:37:21.222410] [0x00007fa0627fc640] [debug]   Received 2818048 of 2827344 bytes.
[2024-04-01 15:37:21.224001] [0x00007fa0627fc640] [debug]   Received 2827344 of 2827344 bytes.
[2024-04-01 15:37:21.280945] [0x00007fa0627fc640] [info]    Upload complete.                       <<<<<----------------
Fast-loading "/ansys_inc/v242/fluent/fluent24.2.0/addons/afd/lib/hdfio.bin"
Done.

Reading from 3a77a99c3862:"/mnt/pyfluent/mixing_elbow.msh.h5" in NODE0 mode ...           <<<<<----------------
  Reading mesh ...
       17822 cells,     1 cell zone  ...
          17822 mixed cells,  zone id: 87
       91581 faces,     7 face zones ...
           2001 polygonal symmetry faces,  zone id: 29
             55 polygonal velocity-inlet faces,  zone id: 30
            152 polygonal velocity-inlet faces,  zone id: 31
            155 polygonal pressure-outlet faces,  zone id: 32
            268 polygonal wall faces,  zone id: 33
           2168 polygonal wall faces,  zone id: 34
          86782 mixed interior faces,  zone id: 89
       66417 nodes,     3 node zones ...

Building...
     mesh
     materials,
     interface,
     domains,
     zones,
        Skipping thread 20 of domain 1 (not referenced by grid).
        Skipping thread 21 of domain 1 (not referenced by grid).
        Skipping thread 22 of domain 1 (not referenced by grid).
        Skipping thread 23 of domain 1 (not referenced by grid).
        Skipping thread 24 of domain 1 (not referenced by grid).
        Skipping thread 25 of domain 1 (not referenced by grid).
        Skipping thread 26 of domain 1 (not referenced by grid).
        Skipping thread 27 of domain 1 (not referenced by grid).
        Skipping thread 28 of domain 1 (not referenced by grid).
        symmetry-xyplane
        hot-inlet
        cold-inlet
        outlet
        wall-inlet
        wall-elbow
        interior--elbow-fluid
        elbow-fluid
     parallel,
Done.
Mesh is now scaled to meters.

Fluent writes to "/mnt/pyfluent/docker_written_latest_mixing_elbow.cas.h5"

File transfer service downloads to "/mnt/c/Users/hpohekar/pyfluent" (current working directory).

>>> solver.file.write_case(file_name="docker_written_latest_mixing_elbow.cas.h5")

Writing to 3a77a99c3862:"/mnt/pyfluent/docker_written_latest_mixing_elbow.cas.h5" in NODE0 mode and compression level 1 ...
Grouping cells for Laplace smoothing ...
       17822 cells,     1 zone  ...
       91581 faces,     7 zones ...
       66417 nodes,     1 zone  ...
  Done.
Done.
[2024-04-01 15:39:54.712826] [0x00007fa061ffb640] [info]    Initializing download of file docker_written_latest_mixing_elbow.cas.h5
  file size: 3095730
  chunk size: 65536
[2024-04-01 15:39:54.713022] [0x00007fa061ffb640] [debug]   Sending chunk 0
[2024-04-01 15:39:54.713211] [0x00007fa061ffb640] [debug]   Sending chunk 1
[2024-04-01 15:39:54.713295] [0x00007fa061ffb640] [debug]   Sending chunk 2
[2024-04-01 15:39:54.713387] [0x00007fa061ffb640] [debug]   Sending chunk 3
[2024-04-01 15:39:54.713427] [0x00007fa061ffb640] [debug]   Sending chunk 4
[2024-04-01 15:39:54.713510] [0x00007fa061ffb640] [debug]   Sending chunk 5
[2024-04-01 15:39:54.713552] [0x00007fa061ffb640] [debug]   Sending chunk 6
[2024-04-01 15:39:54.713638] [0x00007fa061ffb640] [debug]   Sending chunk 7
[2024-04-01 15:39:54.713675] [0x00007fa061ffb640] [debug]   Sending chunk 8
[2024-04-01 15:39:54.713736] [0x00007fa061ffb640] [debug]   Sending chunk 9
[2024-04-01 15:39:54.713773] [0x00007fa061ffb640] [debug]   Sending chunk 10
[2024-04-01 15:39:54.713835] [0x00007fa061ffb640] [debug]   Sending chunk 11
[2024-04-01 15:39:54.713870] [0x00007fa061ffb640] [debug]   Sending chunk 12
[2024-04-01 15:39:54.713933] [0x00007fa061ffb640] [debug]   Sending chunk 13
[2024-04-01 15:39:54.713971] [0x00007fa061ffb640] [debug]   Sending chunk 14
[2024-04-01 15:39:54.714004] [0x00007fa061ffb640] [debug]   Sending chunk 15
[2024-04-01 15:39:54.714065] [0x00007fa061ffb640] [debug]   Sending chunk 16
[2024-04-01 15:39:54.714129] [0x00007fa061ffb640] [debug]   Sending chunk 17
[2024-04-01 15:39:54.714191] [0x00007fa061ffb640] [debug]   Sending chunk 18
[2024-04-01 15:39:54.714239] [0x00007fa061ffb640] [debug]   Sending chunk 19
[2024-04-01 15:39:54.714297] [0x00007fa061ffb640] [debug]   Sending chunk 20
[2024-04-01 15:39:54.714332] [0x00007fa061ffb640] [debug]   Sending chunk 21
[2024-04-01 15:39:54.714368] [0x00007fa061ffb640] [debug]   Sending chunk 22
[2024-04-01 15:39:54.714453] [0x00007fa061ffb640] [debug]   Sending chunk 23
[2024-04-01 15:39:54.714488] [0x00007fa061ffb640] [debug]   Sending chunk 24
[2024-04-01 15:39:54.714524] [0x00007fa061ffb640] [debug]   Sending chunk 25
[2024-04-01 15:39:54.714587] [0x00007fa061ffb640] [debug]   Sending chunk 26
[2024-04-01 15:39:54.714622] [0x00007fa061ffb640] [debug]   Sending chunk 27
[2024-04-01 15:39:54.714659] [0x00007fa061ffb640] [debug]   Sending chunk 28
[2024-04-01 15:39:54.714742] [0x00007fa061ffb640] [debug]   Sending chunk 29
[2024-04-01 15:39:54.714805] [0x00007fa061ffb640] [debug]   Sending chunk 30
[2024-04-01 15:39:54.714841] [0x00007fa061ffb640] [debug]   Sending chunk 31
[2024-04-01 15:39:54.714875] [0x00007fa061ffb640] [debug]   Sending chunk 32
[2024-04-01 15:39:54.714908] [0x00007fa061ffb640] [debug]   Sending chunk 33
[2024-04-01 15:39:54.714974] [0x00007fa061ffb640] [debug]   Sending chunk 34
[2024-04-01 15:39:54.715034] [0x00007fa061ffb640] [debug]   Sending chunk 35
[2024-04-01 15:39:54.715092] [0x00007fa061ffb640] [debug]   Sending chunk 36
[2024-04-01 15:39:54.715126] [0x00007fa061ffb640] [debug]   Sending chunk 37
[2024-04-01 15:39:54.715162] [0x00007fa061ffb640] [debug]   Sending chunk 38
[2024-04-01 15:39:54.715191] [0x00007fa061ffb640] [debug]   Sending chunk 39
[2024-04-01 15:39:54.715255] [0x00007fa061ffb640] [debug]   Sending chunk 40
[2024-04-01 15:39:54.715373] [0x00007fa061ffb640] [debug]   Sending chunk 41
[2024-04-01 15:39:54.715455] [0x00007fa061ffb640] [debug]   Sending chunk 42
[2024-04-01 15:39:54.715488] [0x00007fa061ffb640] [debug]   Sending chunk 43
[2024-04-01 15:39:54.715559] [0x00007fa061ffb640] [debug]   Sending chunk 44
[2024-04-01 15:39:54.715644] [0x00007fa061ffb640] [debug]   Sending chunk 45
[2024-04-01 15:39:54.715701] [0x00007fa061ffb640] [debug]   Sending chunk 46
[2024-04-01 15:39:54.715733] [0x00007fa061ffb640] [debug]   Sending final partial chunk.
[2024-04-01 15:39:54.715763] [0x00007fa061ffb640] [info]    Download complete.
>>>

@hpohekar hpohekar marked this pull request as draft March 18, 2024 12:25
@hpohekar hpohekar linked an issue Mar 18, 2024 that may be closed by this pull request
@mkundu1
Copy link
Contributor

mkundu1 commented Mar 18, 2024

@hpohekar Can we demonstrate the following?

os.chdir(<client-pwd>)
copy the case file to <client-pwd>
launch_fluent(cwd=<server-pwd>)
read_case(file_name=<case filename without the directory path>)

<client-pwd> and <server-pwd> will be different directories and file will be uploaded from <client-pwd> to <server-pwd> by the file-transfer service.

@hpohekar hpohekar marked this pull request as ready for review April 1, 2024 15:47
@hpohekar hpohekar marked this pull request as draft April 12, 2024 10:40
@hpohekar hpohekar marked this pull request as ready for review April 12, 2024 10:52
@hpohekar
Copy link
Collaborator Author

hpohekar commented Apr 12, 2024

We are going to add tests for both Local and Remote FTS

@hpohekar Can we demonstrate the following?

os.chdir(<client-pwd>)
copy the case file to <client-pwd>
launch_fluent(cwd=<server-pwd>)
read_case(file_name=<case filename without the directory path>)

<client-pwd> and <server-pwd> will be different directories and file will be uploaded from <client-pwd> to <server-pwd> by the file-transfer service.

@mkundu1

So in this demo are we instantiating Local FTS independent of Fluent session like for e.g.

from ansys.fluent.core.utils.file_transfer_service import LocalFileTransferStrategy
fts = LocalFileTransferStrategy()

from ansys.fluent.core.examples import download_file
import_file_name = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")

fts.upload(file_name=import_file_name, remote_file_name="uploaded_mixing_elbow.cas.h5")

from ansys.fluent.core import launch_fluent
solver = launch_fluent()

solver.file.read_case(file_name="uploaded_mixing_elbow.cas.h5")

@mkundu1
Copy link
Contributor

mkundu1 commented Apr 12, 2024

We are going to add tests for both Local and Remote FTS

@hpohekar Can we demonstrate the following?

os.chdir(<client-pwd>)
copy the case file to <client-pwd>
launch_fluent(cwd=<server-pwd>)
read_case(file_name=<case filename without the directory path>)

<client-pwd> and <server-pwd> will be different directories and file will be uploaded from <client-pwd> to <server-pwd> by the file-transfer service.

@mkundu1

So in this demo are we instantiating Local FTS independent of Fluent session like for e.g.

from ansys.fluent.core.utils.file_transfer_service import LocalFileTransferStrategy
fts = LocalFileTransferStrategy()

from ansys.fluent.core.examples import download_file
import_file_name = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")

fts.upload(file_name=import_file_name, remote_file_name="uploaded_mixing_elbow.cas.h5")

from ansys.fluent.core import launch_fluent
solver = launch_fluent()

solver.file.read_case(file_name="uploaded_mixing_elbow.cas.h5")

Does the user need to call fts.upload explicitly? I thought that can happen behind the scene during read_case.

Also the read_case call should accept the client-side filename (solver.file.read_case(file_name="mixing_elbow.cas.h5")). I think we can figure out a concerte logic for fts.upload(file_name=<X>, remote_file_name=<Y>). X, Y will depend on client working directory, server working directoy and the volume mapping of the container (for container launch scenario).

@hpohekar
Copy link
Collaborator Author

hpohekar commented Apr 12, 2024

We are going to add tests for both Local and Remote FTS

@hpohekar Can we demonstrate the following?

os.chdir(<client-pwd>)
copy the case file to <client-pwd>
launch_fluent(cwd=<server-pwd>)
read_case(file_name=<case filename without the directory path>)

<client-pwd> and <server-pwd> will be different directories and file will be uploaded from <client-pwd> to <server-pwd> by the file-transfer service.

@mkundu1
So in this demo are we instantiating Local FTS independent of Fluent session like for e.g.

from ansys.fluent.core.utils.file_transfer_service import LocalFileTransferStrategy
fts = LocalFileTransferStrategy()

from ansys.fluent.core.examples import download_file
import_file_name = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")

fts.upload(file_name=import_file_name, remote_file_name="uploaded_mixing_elbow.cas.h5")

from ansys.fluent.core import launch_fluent
solver = launch_fluent()

solver.file.read_case(file_name="uploaded_mixing_elbow.cas.h5")

Does the user need to call fts.upload explicitly? I thought that can happen behind the scene during read_case.

Also the read_case call should accept the client-side filename (solver.file.read_case(file_name="mixing_elbow.cas.h5")). I think we can figure out a concerte logic for fts.upload(file_name=<X>, remote_file_name=<Y>). X, Y will depend on client working directory, server working directoy and the volume mapping of the container (for container launch scenario).

@mkundu1

Does the user need to call fts.upload explicitly? - Yes, for scenario 1.

Does the user need to call fts.upload explicitly? - No, for scenario 2.

Scenario 1: To use - solver.file.read_case(file_name="uploaded_mixing_elbow.cas.h5")

Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ansys.fluent.core.utils.file_transfer_service import LocalFileTransferStrategy                   
>>> fts = LocalFileTransferStrategy()
>>> from ansys.fluent.core.examples import download_file                                
>>> import_file_name = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
File already exists. File path:
C:\Users\hpohekar\AppData\Local\Ansys\ansys_fluent_core\examples\mixing_elbow.cas.h5
>>> fts.upload(file_name=import_file_name, remote_file_name="uploaded_mixing_elbow.cas.h5")
>>> from ansys.fluent.core import launch_fluent
>>> solver = launch_fluent(cwd=r"D:\ANSYSDev\vNNN\fluent")
pyfluent.launcher WARNING: These specified arguments are only supported when starting local standalone Fluent clients: cwd.
>>> solver.file.read_case(file_name="uploaded_mixing_elbow.cas.h5")
pyfluent.settings_api WARNING: Mismatch between generated file and server object info. Dynamically created settings classes will be used.
Fast-loading "D:\ANSYSDev\vNNN\fluent\fluent24.2\\addons\afd\lib\hdfio.bin"
Done.
Multicore SMT processors detected. Processor affinity set!

**Reading from AAPQ13pUvWxQtxN:"D:\ANSYSDev\vNNN\fluent\uploaded_mixing_elbow.cas.h5"** in NODE0 mode ...
  Reading mesh ...
       17822 cells,     1 cell zone  ...
          17822 mixed cells,  zone id: 87
       91581 faces,     7 face zones ...
           2168 polygonal wall faces,  zone id: 34
            268 polygonal wall faces,  zone id: 33
            155 polygonal pressure-outlet faces,  zone id: 32
            152 polygonal velocity-inlet faces,  zone id: 31
             55 polygonal velocity-inlet faces,  zone id: 30
           2001 polygonal symmetry faces,  zone id: 29
          86782 mixed interior faces,  zone id: 89
       66417 nodes,     1 node zone  ...
Warning: reading 2 partition grid onto 1 compute node machine.
         Combining every 2 partitions.
  Done.


Building...
     mesh
     materials,
     interface,
     domains,
        mixture
     zones,
        wall-elbow
        wall-inlet
        outlet
        cold-inlet
        hot-inlet
        symmetry-xyplane
        interior--elbow-fluid
        elbow-fluid
     parallel,
Done.
>>> solver.file.write_case(file_name="download_mixing_elbow.cas.h5")

**Writing to AAPQ13pUvWxQtxN:"D:\ANSYSDev\vNNN\fluent\download_mixing_elbow.cas.h5"** in NODE0 mode and compression level 1 ...
Grouping cells for Laplace smoothing ...
       17822 cells,     1 zone  ...
       91581 faces,     7 zones ...
       66417 nodes,     1 zone  ...
  Done.
Done.
>>> fts.file_exists_on_remote("download_mixing_elbow.cas.h5")                                             
True
>>> fts.file_exists_on_remote("uploaded_mixing_elbow.cas.h5") 
True
>>> ^Z

Scenario 2: To use - solver.file.read_case(file_name=import_file_name).

Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ansys.fluent.core.examples import download_file                                    
>>> import_file_name = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
File already exists. File path:
C:\Users\hpohekar\AppData\Local\Ansys\ansys_fluent_core\examples\mixing_elbow.cas.h5
>>> from ansys.fluent.core import launch_fluent                                             
>>> solver = launch_fluent(cwd=r"D:\ANSYSDev\vNNN\fluent", show_gui=True) 
D:\Repos\pyfluent\src\ansys\fluent\core\launcher\launcher.py:308: PyFluentDeprecationWarning: 'show_gui' is deprecated, use 'ui_mode' instead
  warnings.warn(
>>> solver.file.read_case(file_name=import_file_name)                                
pyfluent.settings_api WARNING: Mismatch between generated file and server object info. Dynamically created settings classes will be used.
Fast-loading "D:\ANSYSDev\vNNN\fluent\fluent24.2\\addons\afd\lib\hdfio.bin"
Done.
Multicore SMT processors detected. Processor affinity set!

**Reading from AAPQ13pUvWxQtxN:"D:\ANSYSDev\vNNN\fluent\mixing_elbow.cas.h5"** in NODE0 mode ... <<<<----------
  Reading mesh ...
       17822 cells,     1 cell zone  ...
          17822 mixed cells,  zone id: 87
       91581 faces,     7 face zones ...
           2168 polygonal wall faces,  zone id: 34
            268 polygonal wall faces,  zone id: 33
            155 polygonal pressure-outlet faces,  zone id: 32
            152 polygonal velocity-inlet faces,  zone id: 31
             55 polygonal velocity-inlet faces,  zone id: 30
           2001 polygonal symmetry faces,  zone id: 29
          86782 mixed interior faces,  zone id: 89
       66417 nodes,     1 node zone  ...
Warning: reading 2 partition grid onto 1 compute node machine.
         Combining every 2 partitions.
  Done.


Building...
     mesh
     materials,
     interface,
     domains,
        mixture
     zones,
        wall-elbow
        wall-inlet
        outlet
        cold-inlet
        hot-inlet
        symmetry-xyplane
        interior--elbow-fluid
        elbow-fluid
     parallel,
Done.
>>> solver.file.write_case(file_name="downloaded_mixing_elbow.cas.h5")                      

**Writing to AAPQ13pUvWxQtxN:"D:\ANSYSDev\vNNN\fluent\downloaded_mixing_elbow.cas.h5"** in NODE0 mode and compression level 1 ...
Grouping cells for Laplace smoothing ...
       17822 cells,     1 zone  ...
       91581 faces,     7 zones ...
       66417 nodes,     1 zone  ...
  Done.
Done.
>>> solver.file_exists_on_remote("mixing_elbow.cas.h5")
True
>>> solver.file_exists_on_remote("downloaded_mixing_elbow.cas.h5")
True
>>>

@mkundu1
Copy link
Contributor

mkundu1 commented Apr 12, 2024

We are going to add tests for both Local and Remote FTS

@hpohekar Can we demonstrate the following?

os.chdir(<client-pwd>)
copy the case file to <client-pwd>
launch_fluent(cwd=<server-pwd>)
read_case(file_name=<case filename without the directory path>)

<client-pwd> and <server-pwd> will be different directories and file will be uploaded from <client-pwd> to <server-pwd> by the file-transfer service.

@mkundu1
So in this demo are we instantiating Local FTS independent of Fluent session like for e.g.

from ansys.fluent.core.utils.file_transfer_service import LocalFileTransferStrategy
fts = LocalFileTransferStrategy()

from ansys.fluent.core.examples import download_file
import_file_name = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")

fts.upload(file_name=import_file_name, remote_file_name="uploaded_mixing_elbow.cas.h5")

from ansys.fluent.core import launch_fluent
solver = launch_fluent()

solver.file.read_case(file_name="uploaded_mixing_elbow.cas.h5")

Does the user need to call fts.upload explicitly? I thought that can happen behind the scene during read_case.
Also the read_case call should accept the client-side filename (solver.file.read_case(file_name="mixing_elbow.cas.h5")). I think we can figure out a concerte logic for fts.upload(file_name=<X>, remote_file_name=<Y>). X, Y will depend on client working directory, server working directoy and the volume mapping of the container (for container launch scenario).

@mkundu1

Does the user need to call fts.upload explicitly? - Yes, for scenario 1.

Does the user need to call fts.upload explicitly? - No, for scenario 2.

Scenario 1: To use - solver.file.read_case(file_name="uploaded_mixing_elbow.cas.h5")

Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ansys.fluent.core.utils.file_transfer_service import LocalFileTransferStrategy                   
>>> fts = LocalFileTransferStrategy()
>>> from ansys.fluent.core.examples import download_file                                
>>> import_file_name = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
File already exists. File path:
C:\Users\hpohekar\AppData\Local\Ansys\ansys_fluent_core\examples\mixing_elbow.cas.h5
>>> fts.upload(file_name=import_file_name, remote_file_name="uploaded_mixing_elbow.cas.h5")
>>> from ansys.fluent.core import launch_fluent
>>> solver = launch_fluent(cwd=r"D:\ANSYSDev\vNNN\fluent")
pyfluent.launcher WARNING: These specified arguments are only supported when starting local standalone Fluent clients: cwd.
>>> solver.file.read_case(file_name="uploaded_mixing_elbow.cas.h5")
pyfluent.settings_api WARNING: Mismatch between generated file and server object info. Dynamically created settings classes will be used.
Fast-loading "D:\ANSYSDev\vNNN\fluent\fluent24.2\\addons\afd\lib\hdfio.bin"
Done.
Multicore SMT processors detected. Processor affinity set!

**Reading from AAPQ13pUvWxQtxN:"D:\ANSYSDev\vNNN\fluent\uploaded_mixing_elbow.cas.h5"** in NODE0 mode ...
  Reading mesh ...
       17822 cells,     1 cell zone  ...
          17822 mixed cells,  zone id: 87
       91581 faces,     7 face zones ...
           2168 polygonal wall faces,  zone id: 34
            268 polygonal wall faces,  zone id: 33
            155 polygonal pressure-outlet faces,  zone id: 32
            152 polygonal velocity-inlet faces,  zone id: 31
             55 polygonal velocity-inlet faces,  zone id: 30
           2001 polygonal symmetry faces,  zone id: 29
          86782 mixed interior faces,  zone id: 89
       66417 nodes,     1 node zone  ...
Warning: reading 2 partition grid onto 1 compute node machine.
         Combining every 2 partitions.
  Done.


Building...
     mesh
     materials,
     interface,
     domains,
        mixture
     zones,
        wall-elbow
        wall-inlet
        outlet
        cold-inlet
        hot-inlet
        symmetry-xyplane
        interior--elbow-fluid
        elbow-fluid
     parallel,
Done.
>>> solver.file.write_case(file_name="download_mixing_elbow.cas.h5")

**Writing to AAPQ13pUvWxQtxN:"D:\ANSYSDev\vNNN\fluent\download_mixing_elbow.cas.h5"** in NODE0 mode and compression level 1 ...
Grouping cells for Laplace smoothing ...
       17822 cells,     1 zone  ...
       91581 faces,     7 zones ...
       66417 nodes,     1 zone  ...
  Done.
Done.
>>> fts.file_exists_on_remote("download_mixing_elbow.cas.h5")                                             
True
>>> fts.file_exists_on_remote("uploaded_mixing_elbow.cas.h5") 
True
>>> ^Z

Scenario 2: To use - solver.file.read_case(file_name=import_file_name).

Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ansys.fluent.core.examples import download_file                                    
>>> import_file_name = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
File already exists. File path:
C:\Users\hpohekar\AppData\Local\Ansys\ansys_fluent_core\examples\mixing_elbow.cas.h5
>>> from ansys.fluent.core import launch_fluent                                             
>>> solver = launch_fluent(cwd=r"D:\ANSYSDev\vNNN\fluent", show_gui=True) 
D:\Repos\pyfluent\src\ansys\fluent\core\launcher\launcher.py:308: PyFluentDeprecationWarning: 'show_gui' is deprecated, use 'ui_mode' instead
  warnings.warn(
>>> solver.file.read_case(file_name=import_file_name)                                
pyfluent.settings_api WARNING: Mismatch between generated file and server object info. Dynamically created settings classes will be used.
Fast-loading "D:\ANSYSDev\vNNN\fluent\fluent24.2\\addons\afd\lib\hdfio.bin"
Done.
Multicore SMT processors detected. Processor affinity set!

**Reading from AAPQ13pUvWxQtxN:"D:\ANSYSDev\vNNN\fluent\mixing_elbow.cas.h5"** in NODE0 mode ... <<<<----------
  Reading mesh ...
       17822 cells,     1 cell zone  ...
          17822 mixed cells,  zone id: 87
       91581 faces,     7 face zones ...
           2168 polygonal wall faces,  zone id: 34
            268 polygonal wall faces,  zone id: 33
            155 polygonal pressure-outlet faces,  zone id: 32
            152 polygonal velocity-inlet faces,  zone id: 31
             55 polygonal velocity-inlet faces,  zone id: 30
           2001 polygonal symmetry faces,  zone id: 29
          86782 mixed interior faces,  zone id: 89
       66417 nodes,     1 node zone  ...
Warning: reading 2 partition grid onto 1 compute node machine.
         Combining every 2 partitions.
  Done.


Building...
     mesh
     materials,
     interface,
     domains,
        mixture
     zones,
        wall-elbow
        wall-inlet
        outlet
        cold-inlet
        hot-inlet
        symmetry-xyplane
        interior--elbow-fluid
        elbow-fluid
     parallel,
Done.
>>> solver.file.write_case(file_name="downloaded_mixing_elbow.cas.h5")                      

**Writing to AAPQ13pUvWxQtxN:"D:\ANSYSDev\vNNN\fluent\downloaded_mixing_elbow.cas.h5"** in NODE0 mode and compression level 1 ...
Grouping cells for Laplace smoothing ...
       17822 cells,     1 zone  ...
       91581 faces,     7 zones ...
       66417 nodes,     1 zone  ...
  Done.
Done.
>>> solver.file_exists_on_remote("mixing_elbow.cas.h5")
True
>>> solver.file_exists_on_remote("downloaded_mixing_elbow.cas.h5")
True
>>>

Thanks, I think 2 is what users will be looking for. I assume we'll get a similar behaviour with Fluent containers - I'm approving based on that. Please add a unittest later on.

@hpohekar
Copy link
Collaborator Author

We are going to add tests for both Local and Remote FTS

@hpohekar Can we demonstrate the following?

os.chdir(<client-pwd>)
copy the case file to <client-pwd>
launch_fluent(cwd=<server-pwd>)
read_case(file_name=<case filename without the directory path>)

<client-pwd> and <server-pwd> will be different directories and file will be uploaded from <client-pwd> to <server-pwd> by the file-transfer service.

@mkundu1
So in this demo are we instantiating Local FTS independent of Fluent session like for e.g.

from ansys.fluent.core.utils.file_transfer_service import LocalFileTransferStrategy
fts = LocalFileTransferStrategy()

from ansys.fluent.core.examples import download_file
import_file_name = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")

fts.upload(file_name=import_file_name, remote_file_name="uploaded_mixing_elbow.cas.h5")

from ansys.fluent.core import launch_fluent
solver = launch_fluent()

solver.file.read_case(file_name="uploaded_mixing_elbow.cas.h5")

Does the user need to call fts.upload explicitly? I thought that can happen behind the scene during read_case.
Also the read_case call should accept the client-side filename (solver.file.read_case(file_name="mixing_elbow.cas.h5")). I think we can figure out a concerte logic for fts.upload(file_name=<X>, remote_file_name=<Y>). X, Y will depend on client working directory, server working directoy and the volume mapping of the container (for container launch scenario).

@mkundu1
Does the user need to call fts.upload explicitly? - Yes, for scenario 1.
Does the user need to call fts.upload explicitly? - No, for scenario 2.
Scenario 1: To use - solver.file.read_case(file_name="uploaded_mixing_elbow.cas.h5")

Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ansys.fluent.core.utils.file_transfer_service import LocalFileTransferStrategy                   
>>> fts = LocalFileTransferStrategy()
>>> from ansys.fluent.core.examples import download_file                                
>>> import_file_name = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
File already exists. File path:
C:\Users\hpohekar\AppData\Local\Ansys\ansys_fluent_core\examples\mixing_elbow.cas.h5
>>> fts.upload(file_name=import_file_name, remote_file_name="uploaded_mixing_elbow.cas.h5")
>>> from ansys.fluent.core import launch_fluent
>>> solver = launch_fluent(cwd=r"D:\ANSYSDev\vNNN\fluent")
pyfluent.launcher WARNING: These specified arguments are only supported when starting local standalone Fluent clients: cwd.
>>> solver.file.read_case(file_name="uploaded_mixing_elbow.cas.h5")
pyfluent.settings_api WARNING: Mismatch between generated file and server object info. Dynamically created settings classes will be used.
Fast-loading "D:\ANSYSDev\vNNN\fluent\fluent24.2\\addons\afd\lib\hdfio.bin"
Done.
Multicore SMT processors detected. Processor affinity set!

**Reading from AAPQ13pUvWxQtxN:"D:\ANSYSDev\vNNN\fluent\uploaded_mixing_elbow.cas.h5"** in NODE0 mode ...
  Reading mesh ...
       17822 cells,     1 cell zone  ...
          17822 mixed cells,  zone id: 87
       91581 faces,     7 face zones ...
           2168 polygonal wall faces,  zone id: 34
            268 polygonal wall faces,  zone id: 33
            155 polygonal pressure-outlet faces,  zone id: 32
            152 polygonal velocity-inlet faces,  zone id: 31
             55 polygonal velocity-inlet faces,  zone id: 30
           2001 polygonal symmetry faces,  zone id: 29
          86782 mixed interior faces,  zone id: 89
       66417 nodes,     1 node zone  ...
Warning: reading 2 partition grid onto 1 compute node machine.
         Combining every 2 partitions.
  Done.


Building...
     mesh
     materials,
     interface,
     domains,
        mixture
     zones,
        wall-elbow
        wall-inlet
        outlet
        cold-inlet
        hot-inlet
        symmetry-xyplane
        interior--elbow-fluid
        elbow-fluid
     parallel,
Done.
>>> solver.file.write_case(file_name="download_mixing_elbow.cas.h5")

**Writing to AAPQ13pUvWxQtxN:"D:\ANSYSDev\vNNN\fluent\download_mixing_elbow.cas.h5"** in NODE0 mode and compression level 1 ...
Grouping cells for Laplace smoothing ...
       17822 cells,     1 zone  ...
       91581 faces,     7 zones ...
       66417 nodes,     1 zone  ...
  Done.
Done.
>>> fts.file_exists_on_remote("download_mixing_elbow.cas.h5")                                             
True
>>> fts.file_exists_on_remote("uploaded_mixing_elbow.cas.h5") 
True
>>> ^Z

Scenario 2: To use - solver.file.read_case(file_name=import_file_name).

Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ansys.fluent.core.examples import download_file                                    
>>> import_file_name = download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
File already exists. File path:
C:\Users\hpohekar\AppData\Local\Ansys\ansys_fluent_core\examples\mixing_elbow.cas.h5
>>> from ansys.fluent.core import launch_fluent                                             
>>> solver = launch_fluent(cwd=r"D:\ANSYSDev\vNNN\fluent", show_gui=True) 
D:\Repos\pyfluent\src\ansys\fluent\core\launcher\launcher.py:308: PyFluentDeprecationWarning: 'show_gui' is deprecated, use 'ui_mode' instead
  warnings.warn(
>>> solver.file.read_case(file_name=import_file_name)                                
pyfluent.settings_api WARNING: Mismatch between generated file and server object info. Dynamically created settings classes will be used.
Fast-loading "D:\ANSYSDev\vNNN\fluent\fluent24.2\\addons\afd\lib\hdfio.bin"
Done.
Multicore SMT processors detected. Processor affinity set!

**Reading from AAPQ13pUvWxQtxN:"D:\ANSYSDev\vNNN\fluent\mixing_elbow.cas.h5"** in NODE0 mode ... <<<<----------
  Reading mesh ...
       17822 cells,     1 cell zone  ...
          17822 mixed cells,  zone id: 87
       91581 faces,     7 face zones ...
           2168 polygonal wall faces,  zone id: 34
            268 polygonal wall faces,  zone id: 33
            155 polygonal pressure-outlet faces,  zone id: 32
            152 polygonal velocity-inlet faces,  zone id: 31
             55 polygonal velocity-inlet faces,  zone id: 30
           2001 polygonal symmetry faces,  zone id: 29
          86782 mixed interior faces,  zone id: 89
       66417 nodes,     1 node zone  ...
Warning: reading 2 partition grid onto 1 compute node machine.
         Combining every 2 partitions.
  Done.


Building...
     mesh
     materials,
     interface,
     domains,
        mixture
     zones,
        wall-elbow
        wall-inlet
        outlet
        cold-inlet
        hot-inlet
        symmetry-xyplane
        interior--elbow-fluid
        elbow-fluid
     parallel,
Done.
>>> solver.file.write_case(file_name="downloaded_mixing_elbow.cas.h5")                      

**Writing to AAPQ13pUvWxQtxN:"D:\ANSYSDev\vNNN\fluent\downloaded_mixing_elbow.cas.h5"** in NODE0 mode and compression level 1 ...
Grouping cells for Laplace smoothing ...
       17822 cells,     1 zone  ...
       91581 faces,     7 zones ...
       66417 nodes,     1 zone  ...
  Done.
Done.
>>> solver.file_exists_on_remote("mixing_elbow.cas.h5")
True
>>> solver.file_exists_on_remote("downloaded_mixing_elbow.cas.h5")
True
>>>

Thanks, I think 2 is what users will be looking for. I assume we'll get a similar behaviour with Fluent containers - I'm approving based on that. Please add a unittest later on.

@mkundu1

Here we have demonstrated LocalFileTransferStartegy using gRPC FTS for standalone mode.

This PR's description shows similar behavior of RemoteFileTransferStartegy using gRPC FTS for container mode.

@hpohekar hpohekar merged commit d2766c2 into main Apr 17, 2024
26 checks passed
@hpohekar hpohekar deleted the feat/integrate_grpc_based_file_transfer_service branch April 17, 2024 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add file_exists_on_remote() on session level Integrate gRPC-based file transfer service
5 participants