dss-extensions / DSS-Python

Native, "direct" Python bindings (interface) and misc tools for a custom implementation of OpenDSS (EPRI Distribution System Simulator). Based on CFFI, DSS C-API, aiming for full COM API-level compatibility on Windows, Linux and MacOS, while providing various extensions.
https://dss-extensions.org/DSS-Python/
BSD 3-Clause "New" or "Revised" License
58 stars 4 forks source link

dss._cffi_api_util.DSSException #40

Closed BY-hash closed 2 years ago

BY-hash commented 2 years ago

Hello, I'm using dss-python library on linux, with: import dss dss_engine = dss.DSS DSSText = dss_engine.Text

DSSText.Command works fine for editing elements etc. But when I try to use the parallel mechanism of DSS, I get the following errors:

    DSSText.Command =   "ClearAll"           
    DSSText.Command =   'Set Parallel=Yes'     

dss._cffi_api_util.DSSException: (302, 'Unknown Command: "ClearAll" \r\nClearAll ') dss._cffi_api_util.DSSException: (130, 'Unknown parameter "Parallel" for Set Command ')

Why is this happening?

Second, I want to do a parallel for loop, where each for loop does many snap-hot solutions. I have seen one issue here on parallel run, but not specifically on the use case of for loops. Do you have any suggestion regarding such application?

Thank you !

PMeira commented 2 years ago

Hi @BY-hash, Currently those (actors in general, ClearAll and Set Parallel) are not supported.

We're working on implementing those right now. The building blocks are already implemented in the base Pascal library but not 100% ready yet.

Second, I want to do a parallel for loop, where each for loop does many snap-hot solutions. I have seen one issue here on parallel run, but not specifically on the use case of for loops. Do you have any suggestion regarding such application?

Since threading in Python is not great (GIL, etc.), usually we recommend either Python's built-in multiprocessing or tools like dask.distributed. As you noted, we indeed already posted some examples both here on GitHub and in the official OpenDSS forum. Do you have any specific concern or doubt regarding those? If so, we can try to clarify and leave a move complete example for future users.

PS: I'll move this to the dss_python repo

PMeira commented 2 years ago

@BY-hash Some more discussion on the topic at https://github.com/dss-extensions/dss_python/issues/42

And a first beta was uploaded to PyPI with support to the actor/parallel mechanism, if you'd like to try it:

pip install dss-python==0.12.0b1

Closing the issue since it's now addressed, but feel free to reopen if you see fit.