Open lzheng28 opened 3 years ago
Can you try the latest main
branch?
You'll need to use this to install:
pip install git+git://github.com/GMLC-TDC/helics-cli.git@main
You'll need to use this to install:
pip install git+git://github.com/GMLC-TDC/helics-cli.git@main
Just check it, but it leads to another error
(py3.7-helics-2.6.1) lei@lei-VirtualBox:~/Install_package/helics-cli/examples/pi-exchange$ helics
Traceback (most recent call last):
File "/home/lei/anaconda3/envs/py3.7-helics-2.6.1/bin/helics", line 5, in <module>
from helics_cli.cli import cli
File "/home/lei/anaconda3/envs/py3.7-helics-2.6.1/lib/python3.7/site-packages/helics_cli/cli.py", line 18, in <module>
from . import observer
File "/home/lei/anaconda3/envs/py3.7-helics-2.6.1/lib/python3.7/site-packages/helics_cli/observer.py", line 23, in <module>
broker: h.HelicsBroker
AttributeError: module 'helics' has no attribute 'HelicsBroker'
And my helics version is v2.6.1
Can you pip uninstall helics
and then run pip install helics
. You need the one of the pyhelics interfaces instead of the swig interface. You can do pip install helics==2.6.1.post11
if you want HELICS v2.6.1.
See this link for all available releases: https://github.com/GMLC-TDC/pyhelics/releases
Can you
pip uninstall helics
and then runpip install helics
. You need the one of the pyhelics interfaces instead of the swig interface. You can dopip install helics==2.6.1.post11
if you want HELICS v2.6.1.See this link for all available releases: https://github.com/GMLC-TDC/pyhelics/releases
But in my project(C++), I want to use helics dynamic library to compile it, does it influence my project?
It shouldn’t affect. You can use any version. We recommend using the latest since that contains the most bug fixes.
With the pyhelics interface, you can also use an environment variable to tell the Python package to use the helics library in a specific local path.
Okay, I'll have a try after my project is done, because I built helics from source code which took me much time, I'm worried different version of helics (I mean build from source code and pip install helics) will lead to unexpected error, thank you so much.
By the way, if I use pip to install helics, how can I run the hello world example in this link https://docs.helics.org/en/latest/introduction/hello-world.html, I mean how I compile C++ files.
Or should I install both of them, but when I need to do cosimulation in my project, can I use C++ library in one federate and use python helics in another federate?
When you pip install helics
you’ll always get a separate HELICS library which is what is used in Python (this is usually precompiled). Whether or not you use the same library that Python uses to link to your C++ application is up to you. You can also have the pyhelics interface use the same library that your C++ application uses if you want but you can’t do this last thing with the swig interface. Hope that makes sense?
Yes, I will use anaconda to get a new environment to pip install helics, and test it, thank you so much.
When you
pip install helics
you’ll always get a separate HELICS library which is what is used in Python (this is usually precompiled). Whether or not you use the same library that Python uses to link to your C++ application is up to you. You can also have the pyhelics interface use the same library that your C++ application uses if you want but you can’t do this last thing with the swig interface. Hope that makes sense?
I've created a new environment with anaconda, and then pip install helics
, and pip install git+git://github.com/GMLC-TDC/helics-cli.git@main
, but the error is still here.
Successfully installed helics-2.7.0.post8
(helics-cli) lei@lei-VirtualBox:~$ helics
Traceback (most recent call last):
File "/home/lei/anaconda3/envs/helics-cli/bin/helics", line 5, in <module>
from helics_cli.cli import cli
File "/home/lei/anaconda3/envs/helics-cli/lib/python3.7/site-packages/helics_cli/cli.py", line 18, in <module>
from . import observer
File "/home/lei/anaconda3/envs/helics-cli/lib/python3.7/site-packages/helics_cli/observer.py", line 23, in <module>
broker: h.HelicsBroker
AttributeError: module 'helics' has no attribute 'HelicsBroker'
And there is a strange thing that, I certainly installed helics-2.7.0 in the new anaconda environment.
>>> h.helicsGetVersion()
'2.6.1 (2020-10-15)'
>>>
I've uninstall helics by "pip uninstall helics" and install it again, but the same thing happened.
If you can delete the python folder in your installation from source that’ll do it.
Yes, it works, but there is still an error if I enter the direction I install helics from source, but it will disappear in other directory.
(helics-cli) lei@lei-VirtualBox:~$ pwd
/home/lei
(helics-cli) lei@lei-VirtualBox:~$ helics
Usage: helics [OPTIONS] COMMAND [ARGS]...
HELICS Runner command line interface
Options:
--version Show the version and exit.
-v, --verbose [x>=0]
--help Show this message and exit.
Commands:
observe
run Run HELICS federation
server
setup Setup HELICS federation
validate Validate config.json
(helics-cli) lei@lei-VirtualBox:~$ cd software/
(helics-cli) lei@lei-VirtualBox:~/software$ ls
boost_1_65_0 ga ga-5.7 helics-2.6.1 openmpi1.8.1 xerces-3.2.3
boost_1_70_0 ga-5.6.1 gridlab-d openmpi openmpi4.1.0 zeromq
(helics-cli) lei@lei-VirtualBox:~/software$ helics
Traceback (most recent call last):
File "/home/lei/anaconda3/envs/helics-cli/bin/helics", line 5, in <module>
from helics_cli.cli import cli
File "/home/lei/anaconda3/envs/helics-cli/lib/python3.7/site-packages/helics_cli/cli.py", line 18, in <module>
from . import observer
File "/home/lei/anaconda3/envs/helics-cli/lib/python3.7/site-packages/helics_cli/observer.py", line 16, in <module>
file_out = logging.FileHandler("observer.log", mode='w')
File "/home/lei/anaconda3/envs/helics-cli/lib/python3.7/logging/__init__.py", line 1087, in __init__
StreamHandler.__init__(self, self._open())
File "/home/lei/anaconda3/envs/helics-cli/lib/python3.7/logging/__init__.py", line 1116, in _open
return open(self.baseFilename, self.mode, encoding=self.encoding)
PermissionError: [Errno 13] Permission denied: '/home/lei/software/observer.log'
(helics-cli) lei@lei-VirtualBox:~/software$
That file handler shouldn’t be created at module import time. I think this is a bug in the cli. If so, I’ll fix it. But also, you don’t seem to have write permissions in the software folder. That’s what is causing this error.
Okay, I got it, but there still another problem.
(helics-cli) lei@lei-VirtualBox:~/Install_package/helics-cli$ helics run --path examples/pi-exchange/runner.json
helics-cli [info]: Running federation: pi-exchange
helics-cli [info]: Running federate pisender1 as a background process
helics-cli [info]: Running federate pisender2 as a background process
helics-cli [info]: Running federate pisender3 as a background process
helics-cli [info]: Running federate pireceiver1 as a background process
helics-cli [info]: Running federate pireceiver2 as a background process
helics-cli [info]: Running federate pireceiver3 as a background process
helics-cli [info]: Running federate observer as a background process
Error: FileNotFoundError: [Errno 2] No such file or directory: './bin/helics': './bin/helics'
And another problem raised when I run the validation
(helics-cli) lei@lei-VirtualBox:~/Install_package/helics-cli$ helics run --path examples/echo-federation/HELICSFederation/config.json
helics-cli [info]: Running federation: HELICSFederation
helics-cli [info]: Running federate Federate1 as a background process
helics-cli [info]: Running federate Federate2 as a background process
helics-cli [info]: Waiting for 2 processes to finish ...
helics-cli [error]: Process Federate1 exited with return code 2
helics-cli [error]: Process Federate2 exited with return code 2
helics-cli [info]: Done.
Error: Process Federate1 has failed, killing other processes
Exception in thread Thread-1:
Traceback (most recent call last):
File "/home/lei/anaconda3/envs/helics-cli/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/home/lei/anaconda3/envs/helics-cli/lib/python3.7/site-packages/helics_cli/status_checker.py", line 39, in run
raise HELICSRuntimeError("Error has occurred")
helics_cli.exceptions.HELICSRuntimeError: Error has occurred
I don't understand why it is trying to run the observer for you. Can you share the output of cat examples/pi-exchange/runner.json
? Also, I don't understand why it is trying to run ./bin/helics
?
Here is the output
(helics-cli) lei@lei-VirtualBox:~/Install_package/helics-cli$ cat examples/pi-exchange/runner.json
{
"federates": [
{
"directory": ".",
"exec": "python -u pisender.py 1",
"host": "localhost",
"name": "pisender1"
},
{
"directory": ".",
"exec": "python -u pisender.py 2",
"host": "localhost",
"name": "pisender2"
},
{
"directory": ".",
"exec": "python -u pisender.py 3",
"host": "localhost",
"name": "pisender3"
},
{
"directory": ".",
"exec": "python -u pireceiver.py 1",
"host": "localhost",
"name": "pireceiver1"
},
{
"directory": ".",
"exec": "python -u pireceiver.py 2",
"host": "localhost",
"name": "pireceiver2"
},
{
"directory": ".",
"exec": "python -u pireceiver.py 3",
"host": "localhost",
"name": "pireceiver3"
},
{
"directory": "../../",
"exec": "./bin/helics observe --federates 6",
"host": "localhost",
"name": "observer"
}
],
"name": "pi-exchange"
}
(helics-cli) lei@lei-VirtualBox:~/Install_package/helics-cli$
Remove the last block, i.e.
{
"directory": "../../",
"exec": "./bin/helics observe --federates 6",
"host": "localhost",
"name": "observer"
}
Or use the most recent commit in helics-cli
.
Remove the last block, i.e.
{ "directory": "../../", "exec": "./bin/helics observe --federates 6", "host": "localhost", "name": "observer" }
Or use the most recent commit in
helics-cli
.
Yes, this works, but the last problem is still here.
(helics-cli) lei@lei-VirtualBox:~/Install_package/helics-cli$ helics run --path examples/echo-federation/HELICSFederation/config.json
helics-cli [info]: Running federation: HELICSFederation
helics-cli [info]: Running federate Federate1 as a background process
helics-cli [info]: Running federate Federate2 as a background process
helics-cli [info]: Waiting for 2 processes to finish ...
helics-cli [error]: Process Federate1 exited with return code 2
helics-cli [error]: Process Federate2 exited with return code 2
helics-cli [info]: Done.
Error: Process Federate1 has failed, killing other processes
Exception in thread Thread-1:
Traceback (most recent call last):
File "/home/lei/anaconda3/envs/helics-cli/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/home/lei/Install_package/helics-cli/helics_cli/status_checker.py", line 39, in run
raise HELICSRuntimeError("Error has occurred")
helics_cli.exceptions.HELICSRuntimeError: Error has occurred
Please note that the path of the json file is in examples/echo-federation/HELICSFederation/config.json
I made some changes that should fix this. You’ll need to update to the latest version of helics-cli
. Can you delete the echo-federation
folder and try again?
This works for me with the latest:
$ helics --version
helics, version 0.5.1
$ helics setup
~/gitrepos/helics-cli/HELICSFederation/config.json
$ helics run --path HELICSFederation/config.json
helics-cli [info]: Running federation: HELICSFederation
helics-cli [info]: Running federate Federate1 as a background process
helics-cli [info]: Running federate Federate2 as a background process
helics-cli [info]: Waiting for 2 processes to finish ...
helics-cli [info]: Done.
Yes, this works for me, but I think you can revise the README.md, so that it will include HELICSFederation in the path.
When I run the example of pi-exchange, the following error happens
Is there anything I forget to do before run it? I just install the helics-cli, and I also cannot run the validation successfully.