Skip to content
Snippets Groups Projects

Fix pyOpenPASS

Merged Naida Goro requested to merge fix/pyOpenPASS into develop
2 files
+ 11
37
Compare changes
  • Side-by-side
  • Inline
Files
2
################################################################################
# Copyright (c) 2020-2021 in-tech GmbH
# 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
# 2022-2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
@@ -116,8 +116,7 @@ def _extract_agents_from_trace(root, invocation) -> DataFrame:
rows = []
for run_result in root.findall(f"RunResults/RunResult[@RunId='{invocation}']"):
for a in _parse_agents(run_result):
rows.append(_transform_flat_dict_to_dataframe(a.get()))
rows.extend(_parse_agents(run_result))
df = concat(rows, ignore_index=True) if len(rows) else pd.DataFrame(columns=['AgentId'])
df['AgentId'] = df['AgentId'].astype('int64')
@@ -156,39 +155,11 @@ def _parse_events(run_result):
return events
@dataclass(init=True)
class Agent:
id: int
AgentTypeGroupName: str
AgentTypeName: str
VehicleModelType: str
DriverProfileName: str
AgentType: str
def get(self):
return {
'AgentId': self.id,
'AgentTypeGroupName': self.AgentTypeGroupName,
'AgentTypeName': self.AgentTypeName,
'VehicleModelType': self.VehicleModelType,
'DriverProfileName': self.DriverProfileName,
'AgentType': self.AgentType
}
def _parse_agents(run_result):
return map(lambda agent:
Agent(
str(agent.attrib['Id']),
agent.attrib['AgentTypeGroupName'],
agent.attrib['AgentTypeName'],
agent.attrib['VehicleModelType'],
agent.attrib['DriverProfileName'],
agent.attrib['AgentType']
),
run_result.find('Agents'))
for agent in run_result.find('Agents'):
df = DataFrame([dict(agent.attrib)])
df.rename(columns={'Id': 'AgentId'}, inplace=True)
yield df
def _parse_entities(tag, event):
parsed_entities = []
Loading