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

new implementation for multicontainer use case #67

Merged
merged 14 commits into from
Apr 16, 2024
Merged

new implementation for multicontainer use case #67

merged 14 commits into from
Apr 16, 2024

Conversation

AadilLatif
Copy link
Collaborator

No description provided.

Copy link
Contributor

@josephmckinsey josephmckinsey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to get the docker compose running by submitting the system.json to the configure endpoint and then running.

I first tried submitting the multicontainer.json, and I was a bit surprised that didn't work. I got this error:

build-oedisi_broker-1                    | ERROR:    Exception in ASGI application
build-oedisi_broker-1                    | Traceback (most recent call last):
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 198, in _new_conn
build-oedisi_broker-1                    |     sock = connection.create_connection(
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 85, in create_connection
build-oedisi_broker-1                    |     raise err
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 73, in create_connection
build-oedisi_broker-1                    |     sock.connect(sa)
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/gevent/_socketcommon.py", line 590, in connect
build-oedisi_broker-1                    |     self._internal_connect(address)
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/gevent/_socketcommon.py", line 634, in _internal_connect
build-oedisi_broker-1                    |     raise _SocketError(err, strerror(err))
build-oedisi_broker-1                    | ConnectionRefusedError: [Errno 111] Connection refused
build-oedisi_broker-1                    | 
build-oedisi_broker-1                    | The above exception was the direct cause of the following exception:
build-oedisi_broker-1                    | 
build-oedisi_broker-1                    | Traceback (most recent call last):
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 793, in urlopen
build-oedisi_broker-1                    |     response = self._make_request(
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 496, in _make_request
build-oedisi_broker-1                    |     conn.request(
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 400, in request
build-oedisi_broker-1                    |     self.endheaders()
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/http/client.py", line 1277, in endheaders
build-oedisi_broker-1                    |     self._send_output(message_body, encode_chunked=encode_chunked)
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/http/client.py", line 1037, in _send_output
build-oedisi_broker-1                    |     self.send(msg)
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/http/client.py", line 975, in send
build-oedisi_broker-1                    |     self.connect()
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 238, in connect
build-oedisi_broker-1                    |     self.sock = self._new_conn()
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 213, in _new_conn
build-oedisi_broker-1                    |     raise NewConnectionError(
build-oedisi_broker-1                    | urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fbaca42d600>: Failed to establish a new connection: [Errno 111] Connection refused
build-oedisi_broker-1                    | 
build-oedisi_broker-1                    | The above exception was the direct cause of the following exception:
build-oedisi_broker-1                    | 
build-oedisi_broker-1                    | Traceback (most recent call last):
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 486, in send
build-oedisi_broker-1                    |     resp = conn.urlopen(
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 847, in urlopen
build-oedisi_broker-1                    |     retries = retries.increment(
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/urllib3/util/retry.py", line 515, in increment
build-oedisi_broker-1                    |     raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
build-oedisi_broker-1                    | urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='10.5.0.3', port=5678): Max retries exceeded with url: /configure/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fbaca42d600>: Failed to establish a new connection: [Errno 111] Connection refused'))
build-oedisi_broker-1                    | 
build-oedisi_broker-1                    | During handling of the above exception, another exception occurred:
build-oedisi_broker-1                    | 
build-oedisi_broker-1                    | Traceback (most recent call last):
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 412, in run_asgi
build-oedisi_broker-1                    |     result = await app(  # type: ignore[func-returns-value]
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
build-oedisi_broker-1                    |     return await self.app(scope, receive, send)
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in __call__
build-oedisi_broker-1                    |     await super().__call__(scope, receive, send)
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/starlette/applications.py", line 123, in __call__
build-oedisi_broker-1                    |     await self.middleware_stack(scope, receive, send)
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 186, in __call__
build-oedisi_broker-1                    |     raise exc
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 164, in __call__
build-oedisi_broker-1                    |     await self.app(scope, receive, _send)
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
build-oedisi_broker-1                    |     await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
build-oedisi_broker-1                    |     raise exc
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
build-oedisi_broker-1                    |     await app(scope, receive, sender)
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 758, in __call__
build-oedisi_broker-1                    |     await self.middleware_stack(scope, receive, send)
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 778, in app
build-oedisi_broker-1                    |     await route.handle(scope, receive, send)
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 299, in handle
build-oedisi_broker-1                    |     await self.app(scope, receive, send)
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 79, in app
build-oedisi_broker-1                    |     await wrap_app_handling_exceptions(app, request)(scope, receive, send)
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
build-oedisi_broker-1                    |     raise exc
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
build-oedisi_broker-1                    |     await app(scope, receive, sender)
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 74, in app
build-oedisi_broker-1                    |     response = await func(request)
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/fastapi/routing.py", line 278, in app
build-oedisi_broker-1                    |     raw_response = await run_endpoint_function(
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
build-oedisi_broker-1                    |     return await dependant.call(**values)
build-oedisi_broker-1                    |   File "/broker/server.py", line 222, in configure
build-oedisi_broker-1                    |     r = requests.post(url, json=component_model.dict())
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 115, in post
build-oedisi_broker-1                    |     return request("post", url, data=data, json=json, **kwargs)
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 59, in request
build-oedisi_broker-1                    |     return session.request(method=method, url=url, **kwargs)
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 589, in request
build-oedisi_broker-1                    |     resp = self.send(prep, **send_kwargs)
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 703, in send
build-oedisi_broker-1                    |     r = adapter.send(request, **kwargs)
build-oedisi_broker-1                    |   File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 519, in send
build-oedisi_broker-1                    |     raise ConnectionError(e, request=request)
build-oedisi_broker-1                    | requests.exceptions.ConnectionError: HTTPConnectionPool(host='10.5.0.3', port=5678): Max retries exceeded with url: /configure/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fbaca42d600>: Failed to establish a new connection: [Errno 111] Connection refused'))

I also tried to just hit run and got a bunch of errors like helics broker duplicate name or broker core has already initialized.

Eventually I remembered you added this other system.json. What's the difference? Was I supposed to use the scenarios/multicontainer.json to build the dockerfiles and then submit a different one.

Finally, I was unable to get the kubernetes one working at all, since there doesn't seem to be a broker.yaml when I build.

broker/__pycache__/server.cpython-312.pyc Outdated Show resolved Hide resolved
broker/server.py Outdated Show resolved Hide resolved
broker/server.py Outdated Show resolved Hide resolved
broker/server.py Outdated Show resolved Hide resolved
system.json Outdated Show resolved Hide resolved
@josephmckinsey
Copy link
Contributor

I've been running more tests in docker compose at least.

  1. I don't think we need so many folders for the different sensors and recorders. The docker compose.yml should be able to use the same folders
  2. The server.py uses this argv[2] which has been causing me somewhat inconsistent problems. I don't think this variable is even used.
  3. I've recently gotten this error on sensors. I had to cancel things to even catch this error
build-oedisi_sensor_power_imaginary-1    | ERROR:    Exception in ASGI application
build-oedisi_sensor_power_imaginary-1    | Traceback (most recent call last):
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 408, in run_asgi
build-oedisi_sensor_power_imaginary-1    |     result = await app(  # type: ignore[func-returns-value]
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 69, in __call__
build-oedisi_sensor_power_imaginary-1    |     return await self.app(scope, receive, send)
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in __call__
build-oedisi_sensor_power_imaginary-1    |     await super().__call__(scope, receive, send)
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/starlette/applications.py", line 123, in __call__
build-oedisi_sensor_power_imaginary-1    |     await self.middleware_stack(scope, receive, send)
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 186, in __call__
build-oedisi_sensor_power_imaginary-1    |     raise exc
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 164, in __call__
build-oedisi_sensor_power_imaginary-1    |     await self.app(scope, receive, _send)
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
build-oedisi_sensor_power_imaginary-1    |     await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
build-oedisi_sensor_power_imaginary-1    |     raise exc
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
build-oedisi_sensor_power_imaginary-1    |     await app(scope, receive, sender)
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 758, in __call__
build-oedisi_sensor_power_imaginary-1    |     await self.middleware_stack(scope, receive, send)
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 778, in app
build-oedisi_sensor_power_imaginary-1    |     await route.handle(scope, receive, send)
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 299, in handle
build-oedisi_sensor_power_imaginary-1    |     await self.app(scope, receive, send)
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 79, in app
build-oedisi_sensor_power_imaginary-1    |     await wrap_app_handling_exceptions(app, request)(scope, receive, send)
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
build-oedisi_sensor_power_imaginary-1    |     raise exc
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
build-oedisi_sensor_power_imaginary-1    |     await app(scope, receive, sender)
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 77, in app
build-oedisi_sensor_power_imaginary-1    |     await response(scope, receive, send)
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/starlette/responses.py", line 161, in __call__
build-oedisi_sensor_power_imaginary-1    |     await self.background()
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/starlette/background.py", line 45, in __call__
build-oedisi_sensor_power_imaginary-1    |     await task()
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/starlette/background.py", line 30, in __call__
build-oedisi_sensor_power_imaginary-1    |     await run_in_threadpool(self.func, *self.args, **self.kwargs)
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/starlette/concurrency.py", line 42, in run_in_threadpool
build-oedisi_sensor_power_imaginary-1    |     return await anyio.to_thread.run_sync(func, *args)
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/anyio/to_thread.py", line 56, in run_sync
build-oedisi_sensor_power_imaginary-1    |     return await get_async_backend().run_sync_in_worker_thread(
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 2144, in run_sync_in_worker_thread
build-oedisi_sensor_power_imaginary-1    |     return await future
build-oedisi_sensor_power_imaginary-1    |   File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 851, in run
build-oedisi_sensor_power_imaginary-1    |     result = context.run(func, *args)
build-oedisi_sensor_power_imaginary-1    |   File "/MeasurementComponent/measuring_federate.py", line 150, in run_simulator
build-oedisi_sensor_power_imaginary-1    |     sfed.run()
build-oedisi_sensor_power_imaginary-1    |   File "/MeasurementComponent/measuring_federate.py", line 125, in run
build-oedisi_sensor_power_imaginary-1    |     measurement_transformed = self.transform(measurement, self.measurement)
build-oedisi_sensor_power_imaginary-1    |   File "/MeasurementComponent/measuring_federate.py", line 103, in transform
build-oedisi_sensor_power_imaginary-1    |     new_array = reindex(measurement_array, unique_ids)
build-oedisi_sensor_power_imaginary-1    |   File "/MeasurementComponent/measuring_federate.py", line 33, in reindex
build-oedisi_sensor_power_imaginary-1    |     values=[measurement_array.values[inv_map[i]] for i in indices],
build-oedisi_sensor_power_imaginary-1    |   File "/MeasurementComponent/measuring_federate.py", line 33, in <listcomp>
build-oedisi_sensor_power_imaginary-1    |     values=[measurement_array.values[inv_map[i]] for i in indices],
build-oedisi_sensor_power_imaginary-1    | KeyError: 'detail'

@josephmckinsey
Copy link
Contributor

I also don't think logging is set to INFO in Python for most of the server.py

broker/server.py Outdated Show resolved Hide resolved
@@ -49,7 +51,7 @@ def read_root():
return JSONResponse(response, 200)


@app.get("/sensor/")
@app.get("/sensor")
async def sensor():
logging.info(os.getcwd())
sensor_path = os.path.join(base_path, "sensors", "sensors.json")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unable to add a comment on the right section, but I noticed a couple problems caused by this function when trying to run with SMART-DS as well as deleting the existing sensors.json file

  • We don't even use sensors.json
  • This should almost certainly use asyncio.sleep(1) so that it doesn't block

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will have to resolve this issue once we have sensors published on the helics interface

if not sensor_data:
msg = "empty sensor list"
raise HTTPException(404, msg)
logging.info(sensor_data)
with open("sensors.json", "w") as outfile:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we use smart-ds, we use the create_measurement_lists function to create voltage_ids.json, real_ids.json, and reactive_ids.json, but not a sensors.json.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will have to resolve this issue once we have sensors published on the helics interface

Copy link
Contributor

@josephmckinsey josephmckinsey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from the the problems in the oedisi cor part, the mysterious broker/docker-compose.yml file, and the sensor issue, everything seems to work fine.

broker/docker-compose.yml Outdated Show resolved Hide resolved
system.json Outdated Show resolved Hide resolved
@josephmckinsey
Copy link
Contributor

Aren't the kubernetes files supposed to have a broker.yml? I just realized that the kubernetes side still has that problem.

@AadilLatif
Copy link
Collaborator Author

sensor file moved back

Copy link
Contributor

@josephmckinsey josephmckinsey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also remove the broker-config.yml file from the broker.

broker/server.py Outdated Show resolved Hide resolved
Copy link
Contributor

@josephmckinsey josephmckinsey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also noticed these parentheses on hostname which cause failure for the less common endpoints

broker/server.py Outdated Show resolved Hide resolved
broker/server.py Outdated Show resolved Hide resolved
broker/server.py Outdated Show resolved Hide resolved
@AadilLatif
Copy link
Collaborator Author

I also don't think logging is set to INFO in Python for most of the server.py

I got this to work logger = logging.getLogger('uvicorn.error')
log now appear as expected

Copy link
Contributor

@josephmckinsey josephmckinsey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to go ahead and approve this. I didn't test this last time as much since I think it's just the () that is different.

@AadilLatif AadilLatif merged commit e4bdf56 into main Apr 16, 2024
4 checks passed
@AadilLatif AadilLatif deleted the al/config branch April 16, 2024 19:52
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.

2 participants