eclipse-volttron / volttron-openadr-ven

Apache License 2.0
5 stars 5 forks source link

possible to install this agent the old fashion way? #10

Closed bbartling closed 2 years ago

bbartling commented 3 years ago

Can I install the agent with scripts/install-agent.py just to get up and running for testing purposes?

python scripts/install-agent.py -s examples/volttron-openadr-ven/ -c examples/volttron-openadr-ven/volttron_openadr_ven/config.json --tag openadr_agent

I git cloned the repo, and put in a config.json for the VEN name and VTN server URL.

I just get an error pertain to there is no setup.py and I think this is because agents to be installed new way, like a PyPi method?

Without knowing what I am doing I just gabbed the CSV driver setup.py, changed James Larson to Mark, and copied it into the repo where I am running VOLTTRON on my test bench.

But when I install the agent with install-agent.py, large errors:

ERROR:volttron.platform.packaging:b'/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/grequests.py:22: MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError on Python 3.6. It may also silently lead to incorrect behaviour on Python 3.7. Please monkey-patch earlier. See https://github.com/gevent/gevent/issues/1016. Modules that had direct imports (NOT patched): [\'aiohttp.web (/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/aiohttp/web.py)\', \'aiohttp.web_runner (/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/aiohttp/web_runner.py)\', \'aiohttp.client_reqrep (/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/aiohttp/client_reqrep.py)\', \'aiohttp.client_exceptions (/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/aiohttp/client_exceptions.py)\', \'aiohttp.client (/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/aiohttp/client.py)\', \'aiohttp.connector (/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/aiohttp/connector.py)\']. \n  curious_george.patch_all(thread=False, select=False)\nTraceback (most recent call last):\n  File "setup.py", line 11, in <module>\n    _temp = __import__(agent_module, globals(), locals(), [\'__version__\'], 0)\n  File "/tmp/tmp4qy1dhdn/pkg/volttron_openadr_ven/agent.py", line 55, in <module>\n    from volttron.utils import jsonapi\nImportError: cannot import name \'jsonapi\' from \'volttron.utils\' (/home/dan/Desktop/volttron/volttron/utils/__init__.py)\n'
b'/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/grequests.py:22: MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError on Python 3.6. It may also silently lead to incorrect behaviour on Python 3.7. Please monkey-patch earlier. See https://github.com/gevent/gevent/issues/1016. Modules that had direct imports (NOT patched): [\'aiohttp.web (/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/aiohttp/web.py)\', \'aiohttp.web_runner (/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/aiohttp/web_runner.py)\', \'aiohttp.client_reqrep (/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/aiohttp/client_reqrep.py)\', \'aiohttp.client_exceptions (/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/aiohttp/client_exceptions.py)\', \'aiohttp.client (/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/aiohttp/client.py)\', \'aiohttp.connector (/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/aiohttp/connector.py)\']. \n  curious_george.patch_all(thread=False, select=False)\nTraceback (most recent call last):\n  File "setup.py", line 11, in <module>\n    _temp = __import__(agent_module, globals(), locals(), [\'__version__\'], 0)\n  File "/tmp/tmp4qy1dhdn/pkg/volttron_openadr_ven/agent.py", line 55, in <module>\n    from volttron.utils import jsonapi\nImportError: cannot import name \'jsonapi\' from \'volttron.utils\' (/home/dan/Desktop/volttron/volttron/utils/__init__.py)\n'
Traceback (most recent call last):
  File "scripts/install-agent.py", line 340, in <module>
    if not os.path.isfile(opts.package):
  File "/usr/lib/python3.8/genericpath.py", line 30, in isfile
    st = os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

Thanks for anytime in response getting this up and running.

bbartling commented 3 years ago

This is also the setup.py below

from setuptools import setup, find_packages

MAIN_MODULE = 'agent'

# Find the agent package that contains the main module
packages = find_packages('.')
agent_package = 'volttron_openadr_ven'

# Find the version number from the main module
agent_module = agent_package + '.' + MAIN_MODULE
_temp = __import__(agent_module, globals(), locals(), ['__version__'], 0)
__version__ = _temp.__version__

# Setup
setup(
    name=agent_package + 'agent',
    version=__version__,
    author="Mark Bonicillo",
    author_email="mark.bonicillo@pnnl.gov",
    description="Agent for demonstrating reading values from a device and actuating the device",
    install_requires=['volttron'],
    packages=packages,
    entry_points={
        'setuptools.installation': [
            'eggsecutable = ' + agent_module + ':main',
        ]
    }
)

And config.json below

{
    "ven_name": "dan_test",
    "vtn_url": "http://123.123.234.345:8080/OpenADR2/Simple/2.0b"
}
craig8 commented 3 years ago

This agent will need the interface from the client and utils wheels in order to run. You can build your agent using poetry build and then install that wheel through the "old" way....I haven't done this, however it should be doable. You may have to add the config to it using vpkg however.

bbartling commented 3 years ago

Any chance I could get a tip for the error in the steps I am doing? Is starting up VOLTTRON the old fashion way a thing of the past if we are using Poetry as virtual environment and dependency management?

For example with my very limited experience using VOLTTRON I would only do this in the volttron directory that I git cloned:

volttron$ source env/bin/activate ./start-volttron

I think I am doing something wrong with the poetry virtual environment and trying to also start volttron in my old way of starting volttron with the virtual environment. No matter what way I am trying I am having some issues.

Without doing any of the steps above of the old fashion way of starting volttron, if I do this:

  1. Then cd directory to where I git cloned this open ADR repo in the volttron/examples/volttron-openadr-ven directory on my Ubuntu 20.04 test machine.

Run these poetry steps:

poetry shell NOTE: Poetry needs the command 'python' in order to create a new shell. On Linux, if you only have python3 installed, run the following to link 'python' to 'python3':

$ sudo apt install python-is-python3 Install requirements (env) $ poetry install Install Volttron-specific dependencies for this agent. (env) $ pip install volttron_utils-0.1.1-py3-none-any.whl volttron_client-0.1.2-py3-none-any.whl

I did notice one error on the build of all of this the first time it ran but seems fine on the second time.

I am in this directory now with the poetry virtual environment (volttron-openadr-ven-jMgY9TEO-py3.8) dan@lt-ubuntu:~/Desktop/volttron/examples/volttron-openadr-ven$

change directory back to volttron.

dan@lt-ubuntu:~/Desktop/volttron$ ./start-volttron

This will fail to start volttron.

Starting VOLTTRON verbosely in the background with VOLTTRON_HOME=/home/dan/.volttron
Waiting for VOLTTRON to startup..
VOLTTRON startup failed/timed out. Please check volttron.log for details
(volttron-openadr-ven-jMgY9TEO-py3.8) dan@lt-ubuntu:~/Desktop/volttron$

doing a less volttron.log I do see this:

Traceback (most recent call last):
  File "/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 574, in _build_master
    ws.require(__requires__)
  File "/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 892, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 783, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (cryptography 3.4.7 (/home/dan/Desktop/volttron/env/lib/python3.8/site-packages), Requirement.parse('cryptography==2.3'), {'volttron'})

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/dan/Desktop/volttron/env/bin/volttron", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3089, in <module>
    def _initialize_master_working_set():
  File "/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3072, in _call_aside
    f(*args, **kwargs)
  File "/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3101, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 576, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 589, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/home/dan/Desktop/volttron/env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 778, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'cryptography==2.3' distribution was not found and is required by volttron
craig8 commented 3 years ago

So the way this will work is you have two environments. One for the agent itself and one for the platform. As long as you are running the platform i.e. at 22916 port this should work... I will soon send guidance on how to make agents behave on local platforms from repositories. Should be by monday on this.

bbartling commented 3 years ago

Any further development on this? : )

craig8 commented 2 years ago

This issue is dealt with in this pull request to @bonicim 's repository

https://github.com/bonicim/volttron-openadr-ven/pull/2