Repository navigation
Attribute error when querying NetworkSegment EthRange #3
Copy link
Copy link
Closed
Description
Issue:
When querying sessions.config.config.network_profiles[1].ip_network_segment[1].eth_range I get an error when cyperf/api_client.py#L568 tries to identify the klass of EthRange:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/user/cyperf-testing/.venv/lib/python3.11/site-packages/cyperf/dynamic_model_meta.py", line 361, in get_by_link
field = self.link_based_request(link.name, "GET",
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/cyperf-testing/.venv/lib/python3.11/site-packages/cyperf/dynamic_model_meta.py", line 302, in <lambda>
c.link_based_request = lambda self, link_name, method, return_type=None, body=None, query=[]: cls.link_based_request(self, link_name, method, return_type, body, query)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/cyperf-testing/.venv/lib/python3.11/site-packages/cyperf/dynamic_model_meta.py", line 507, in link_based_request
response = self.api_client.call_api(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/cyperf-testing/.venv/lib/python3.11/site-packages/cyperf/api_client.py", line 385, in call_api
return self.__retry(lambda: self.__call_api(method, url, header_params,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/cyperf-testing/.venv/lib/python3.11/site-packages/cyperf/api_client.py", line 127, in __retry
result = request_func()
^^^^^^^^^^^^^^
File "/home/user/cyperf-testing/.venv/lib/python3.11/site-packages/cyperf/api_client.py", line 385, in <lambda>
return self.__retry(lambda: self.__call_api(method, url, header_params,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/cyperf-testing/.venv/lib/python3.11/site-packages/cyperf/api_client.py", line 359, in __call_api
return DynamicModel.dynamic_wrapper(self.response_deserialize(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/cyperf-testing/.venv/lib/python3.11/site-packages/cyperf/api_client.py", line 425, in response_deserialize
return_data = self.deserialize(response_text, response_type, content_type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/cyperf-testing/.venv/lib/python3.11/site-packages/cyperf/api_client.py", line 527, in deserialize
return self.__deserialize(data, response_type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/cyperf-testing/.venv/lib/python3.11/site-packages/cyperf/api_client.py", line 553, in __deserialize
return {k: self.__deserialize(v, sub_kls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/cyperf-testing/.venv/lib/python3.11/site-packages/cyperf/api_client.py", line 553, in <dictcomp>
return {k: self.__deserialize(v, sub_kls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/cyperf-testing/.venv/lib/python3.11/site-packages/cyperf/api_client.py", line 568, in __deserialize
klass = getattr(cyperf.models, klass)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'cyperf.models' has no attribute 'typing.Any'
It seems that in the IPNetwork model (cyperf/models/ip_network.py#L48), the eth_range attribute does not have the EthRange model defined. It's also worth noting that emulated_router also doesn't appear to have the proper model defined for it.
Workaround:
In cyperf/models/ip_network.py, made the following changes (changes shown as diff):
> from cyperf.models.eth_range import EthRange
47c48
< eth_range: Optional[Dict[str, Any]] = Field(default=None, alias="EthRange")
---
> eth_range: Optional[EthRange] = Field(default=None, alias="EthRange")
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
tsimionescu commentedon Sep 22, 2025
Thank you for reporting this! It should be fixed in the latest build available in PyPI, and in the latest code here. We fixed the definition of the generated Network model to specify the right type (using
EthRangeinstead of the genericDict).Unfortunately we can't address the issues in the OpenAPI spec served by CyPerf Controller v6.0, but we will make sure that future releases of CyPerf controller will include the right information there as well.