fameio 3.1.0__py3-none-any.whl → 3.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. fameio/cli/__init__.py +2 -3
  2. fameio/cli/convert_results.py +6 -4
  3. fameio/cli/make_config.py +6 -4
  4. fameio/cli/options.py +3 -3
  5. fameio/cli/parser.py +43 -31
  6. fameio/input/__init__.py +1 -9
  7. fameio/input/loader/__init__.py +9 -7
  8. fameio/input/loader/controller.py +64 -14
  9. fameio/input/loader/loader.py +14 -7
  10. fameio/input/metadata.py +37 -18
  11. fameio/input/resolver.py +5 -4
  12. fameio/input/scenario/__init__.py +7 -8
  13. fameio/input/scenario/agent.py +52 -19
  14. fameio/input/scenario/attribute.py +28 -29
  15. fameio/input/scenario/contract.py +161 -52
  16. fameio/input/scenario/exception.py +45 -22
  17. fameio/input/scenario/fameiofactory.py +63 -7
  18. fameio/input/scenario/generalproperties.py +17 -6
  19. fameio/input/scenario/scenario.py +111 -28
  20. fameio/input/scenario/stringset.py +27 -8
  21. fameio/input/schema/__init__.py +5 -5
  22. fameio/input/schema/agenttype.py +29 -11
  23. fameio/input/schema/attribute.py +174 -84
  24. fameio/input/schema/java_packages.py +8 -5
  25. fameio/input/schema/schema.py +35 -9
  26. fameio/input/validator.py +58 -42
  27. fameio/input/writer.py +139 -41
  28. fameio/logs.py +23 -17
  29. fameio/output/__init__.py +5 -1
  30. fameio/output/agent_type.py +93 -27
  31. fameio/output/conversion.py +48 -30
  32. fameio/output/csv_writer.py +88 -18
  33. fameio/output/data_transformer.py +12 -21
  34. fameio/output/input_dao.py +68 -32
  35. fameio/output/output_dao.py +26 -4
  36. fameio/output/reader.py +61 -18
  37. fameio/output/yaml_writer.py +18 -9
  38. fameio/scripts/__init__.py +9 -2
  39. fameio/scripts/convert_results.py +144 -52
  40. fameio/scripts/convert_results.py.license +1 -1
  41. fameio/scripts/exception.py +7 -0
  42. fameio/scripts/make_config.py +34 -12
  43. fameio/scripts/make_config.py.license +1 -1
  44. fameio/series.py +132 -47
  45. fameio/time.py +88 -37
  46. fameio/tools.py +9 -8
  47. {fameio-3.1.0.dist-info → fameio-3.2.0.dist-info}/METADATA +19 -13
  48. fameio-3.2.0.dist-info/RECORD +56 -0
  49. {fameio-3.1.0.dist-info → fameio-3.2.0.dist-info}/WHEEL +1 -1
  50. CHANGELOG.md +0 -279
  51. fameio-3.1.0.dist-info/RECORD +0 -56
  52. {fameio-3.1.0.dist-info → fameio-3.2.0.dist-info}/LICENSE.txt +0 -0
  53. {fameio-3.1.0.dist-info → fameio-3.2.0.dist-info}/LICENSES/Apache-2.0.txt +0 -0
  54. {fameio-3.1.0.dist-info → fameio-3.2.0.dist-info}/LICENSES/CC-BY-4.0.txt +0 -0
  55. {fameio-3.1.0.dist-info → fameio-3.2.0.dist-info}/LICENSES/CC0-1.0.txt +0 -0
  56. {fameio-3.1.0.dist-info → fameio-3.2.0.dist-info}/entry_points.txt +0 -0
@@ -1,38 +1,61 @@
1
- # SPDX-FileCopyrightText: 2024 German Aerospace Center <fame@dlr.de>
1
+ # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ from __future__ import annotations
4
5
 
5
- from typing import NoReturn, Any, Union
6
+ from typing import Any
6
7
 
7
8
  from fameio.input import ScenarioError
8
- from fameio.logs import log_error_and_raise, log
9
+ from fameio.logs import log_error
9
10
 
10
11
  _DEFAULT_USED = "Using default value '{}' for missing key '{}'"
11
12
 
12
13
 
13
- def log_and_raise(message: str) -> NoReturn:
14
- """Raises ScenarioError with given `message`"""
15
- log_error_and_raise(ScenarioError(message))
14
+ def log_scenario_error(message: str) -> ScenarioError:
15
+ """
16
+ Creates exception with given `message`, logs it on level "Error" and returns it
16
17
 
18
+ Args:
19
+ message: to be logged and included in the exception if key is missing
17
20
 
18
- def get_or_raise(dictionary: dict, key: str, message: str) -> Union[Any, NoReturn]:
19
- """Returns value associated with `key` in given `dictionary`, or raises ScenarioException if key is missing"""
21
+ Returns:
22
+ created ScenarioError, logged on level "ERROR"
23
+ """
24
+ error = ScenarioError(message)
25
+ log_error(error)
26
+ return error
27
+
28
+
29
+ def get_or_raise(dictionary: dict, key: str, error_message: str) -> Any:
30
+ """
31
+ Returns value associated with `key` in given `dictionary`, or raises exception if key or value is missing
32
+
33
+ Args:
34
+ dictionary: to search the key in
35
+ key: to be searched
36
+ error_message: to be logged and included in the raised exception if key is missing
37
+
38
+ Returns:
39
+ value associated with given key in given dictionary
40
+
41
+ Raises:
42
+ ScenarioError: if given key is not in given dictionary or value is None, logged on level "ERROR"
43
+ """
20
44
  if key not in dictionary or dictionary[key] is None:
21
- log_error_and_raise(ScenarioError(message.format(key)))
22
- else:
23
- return dictionary[key]
45
+ raise log_scenario_error(error_message.format(key))
46
+ return dictionary[key]
24
47
 
25
48
 
26
- def assert_or_raise(assertion: bool, msg: str) -> None:
27
- """Raises new ScenarioError with given `msg` if `assertion` is False"""
28
- if not assertion:
29
- log_error_and_raise(ScenarioError(msg))
49
+ def assert_or_raise(assertion: bool, error_message: str) -> None:
50
+ """
51
+ Raises exception with given `msg` if `assertion` is False
30
52
 
53
+ Args:
54
+ assertion: expression that must be True, else an exception is raised
55
+ error_message: to be logged and included in the raised exception if key is missing
31
56
 
32
- def get_or_default(dictionary: dict, key: str, default_value) -> Any:
33
- """Returns value associated with `key` in given `dictionary`, or the given `default_value` if key is missing"""
34
- if key in dictionary and dictionary[key] is not None:
35
- return dictionary[key]
36
- else:
37
- log().debug(_DEFAULT_USED.format(default_value, key))
38
- return default_value
57
+ Raises:
58
+ ScenarioError: if assertion is False, logged on level "ERROR"
59
+ """
60
+ if not assertion:
61
+ raise log_scenario_error(error_message)
@@ -1,4 +1,4 @@
1
- # SPDX-FileCopyrightText: 2024 German Aerospace Center <fame@dlr.de>
1
+ # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
  from fameio.input.schema import Schema
@@ -9,31 +9,87 @@ from .stringset import StringSet
9
9
 
10
10
 
11
11
  class FameIOFactory:
12
- """Factory used to instantiate the types defined in a scenario file.
12
+ """
13
+ Factory used to instantiate the types defined in a scenario file.
13
14
  This allows a client to subclass some types in order to extend what a scenario can contain.
14
15
  """
15
16
 
16
17
  @staticmethod
17
18
  def new_schema_from_dict(definitions: dict) -> Schema:
18
- """Constructs a new Schema from provided `definitions`"""
19
+ """
20
+ Load given dictionary `definitions` into a new schema
21
+
22
+ Args:
23
+ definitions: dictionary representation of schema
24
+
25
+ Returns:
26
+ new Schema
27
+
28
+ Raises:
29
+ SchemaError: if definitions are incomplete or erroneous, logged on level "ERROR"
30
+ """
19
31
  return Schema.from_dict(definitions)
20
32
 
21
33
  @staticmethod
22
34
  def new_general_properties_from_dict(definitions: dict) -> GeneralProperties:
23
- """Constructs a new GeneralProperties instance from provided `definitions`"""
35
+ """
36
+ Parse general properties from provided `definitions`
37
+
38
+ Args:
39
+ definitions: dictionary representation of general properties
40
+
41
+ Returns:
42
+ new GeneralProperties
43
+
44
+ Raises:
45
+ ScenarioError: if definitions are incomplete or erroneous, logged on level "ERROR"
46
+ """
24
47
  return GeneralProperties.from_dict(definitions)
25
48
 
26
49
  @staticmethod
27
50
  def new_agent_from_dict(definitions: dict) -> Agent:
28
- """Constructs a new Agent from provided `definitions`"""
51
+ """
52
+ Parses an agent from provided `definitions`
53
+
54
+ Args:
55
+ definitions: dictionary representation of an agent
56
+
57
+ Returns:
58
+ new agent
59
+
60
+ Raises:
61
+ ScenarioError: if definitions are incomplete or erroneous, logged on level "ERROR"
62
+ """
29
63
  return Agent.from_dict(definitions)
30
64
 
31
65
  @staticmethod
32
66
  def new_contract_from_dict(definitions: dict) -> Contract:
33
- """Constructs a new Contract from provided `definitions`"""
67
+ """
68
+ Parses contract from given `definitions`
69
+
70
+ Args:
71
+ definitions: dictionary representation of a contract
72
+
73
+ Returns:
74
+ new contract
75
+
76
+ Raises:
77
+ ContractError: if definitions are incomplete or erroneous, logged on level "ERROR"
78
+ """
34
79
  return Contract.from_dict(definitions)
35
80
 
36
81
  @staticmethod
37
82
  def new_string_set_from_dict(definition: StringSet.StringSetType) -> StringSet:
38
- """Constructs a new StringSet from provided `definitions`"""
83
+ """
84
+ Returns string set initialised from `definition`
85
+
86
+ Args:
87
+ definition: dictionary representation of string set
88
+
89
+ Returns:
90
+ new string set
91
+
92
+ Raises:
93
+ StringSetError: if definitions are incomplete or erroneous, logged on level "ERROR"
94
+ """
39
95
  return StringSet.from_dict(definition)
@@ -1,4 +1,4 @@
1
- # SPDX-FileCopyrightText: 2024 German Aerospace Center <fame@dlr.de>
1
+ # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
  from __future__ import annotations
@@ -8,7 +8,7 @@ from typing import Final
8
8
  from fameio.logs import log
9
9
  from fameio.time import FameTime
10
10
  from fameio.tools import keys_to_lower
11
- from .exception import get_or_default, get_or_raise
11
+ from .exception import get_or_raise
12
12
 
13
13
 
14
14
  class GeneralProperties:
@@ -39,9 +39,20 @@ class GeneralProperties:
39
39
 
40
40
  @classmethod
41
41
  def from_dict(cls, definitions: dict) -> GeneralProperties:
42
- """Parse general properties from provided `definitions`"""
42
+ """
43
+ Parse general properties from provided `definitions`
44
+
45
+ Args:
46
+ definitions: dictionary representation of general properties
47
+
48
+ Returns:
49
+ new GeneralProperties
50
+
51
+ Raises:
52
+ ScenarioError: if definitions are incomplete or erroneous, logged on level "ERROR"
53
+ """
43
54
  definitions = keys_to_lower(definitions)
44
- run_id = get_or_default(definitions, GeneralProperties.KEY_RUN, 1)
55
+ run_id = definitions.get(GeneralProperties.KEY_RUN, 1)
45
56
 
46
57
  simulation_definition = keys_to_lower(
47
58
  get_or_raise(
@@ -64,12 +75,12 @@ class GeneralProperties:
64
75
  GeneralProperties._ERR_MISSING_KEY,
65
76
  )
66
77
  )
67
- random_seed = get_or_default(simulation_definition, GeneralProperties.KEY_SEED, 1)
78
+ random_seed = simulation_definition.get(GeneralProperties.KEY_SEED, 1)
68
79
  return cls(run_id, start_time, stop_time, random_seed)
69
80
 
70
81
  def to_dict(self) -> dict:
71
82
  """Serializes the general properties to a dict"""
72
- result = {self.KEY_RUN: self._run_id}
83
+ result: dict = {self.KEY_RUN: self._run_id}
73
84
  simulation_dict = {
74
85
  self.KEY_START: self.simulation_start_time,
75
86
  self.KEY_STOP: self.simulation_stop_time,
@@ -1,19 +1,20 @@
1
- # SPDX-FileCopyrightText: 2024 German Aerospace Center <fame@dlr.de>
1
+ # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
  from __future__ import annotations
5
5
 
6
- from typing import Final
6
+ from typing import Final, Any
7
7
 
8
+ from fameio.input import SchemaError
8
9
  from fameio.input.metadata import Metadata
10
+ from fameio.input.scenario.agent import Agent
11
+ from fameio.input.scenario.contract import Contract
12
+ from fameio.input.scenario.exception import get_or_raise, log_scenario_error
13
+ from fameio.input.scenario.fameiofactory import FameIOFactory
14
+ from fameio.input.scenario.generalproperties import GeneralProperties
15
+ from fameio.input.scenario.stringset import StringSet
9
16
  from fameio.input.schema import Schema
10
17
  from fameio.tools import keys_to_lower
11
- from .agent import Agent
12
- from .contract import Contract
13
- from .exception import get_or_default, get_or_raise
14
- from .fameiofactory import FameIOFactory
15
- from .generalproperties import GeneralProperties
16
- from .stringset import StringSet
17
18
 
18
19
 
19
20
  class Scenario(Metadata):
@@ -26,42 +27,124 @@ class Scenario(Metadata):
26
27
  KEY_STRING_SETS: Final[str] = "StringSets".lower()
27
28
 
28
29
  _MISSING_KEY = "Scenario definition misses required key '{}'."
30
+ _ERR_SCHEMA = "Could not create scenario: Definition of Schema has errors."
31
+ _ERR_STRING_SET = "Could not create scenario: Definition of StringSet '{}' has errors."
32
+ _ERR_MULTI_CONTRACT = "Could not create scenario: Definition of Contracts has errors: {}"
33
+ _ERR_CONTRACT = "Could not create scenario: Definition of Contract has errors: {}"
29
34
 
30
35
  def __init__(self, schema: Schema, general_props: GeneralProperties) -> None:
31
36
  super().__init__()
32
37
  self._schema = schema
33
38
  self._general_props = general_props
34
- self._string_sets = {}
35
- self._agents = []
36
- self._contracts = []
39
+ self._string_sets: dict[str, StringSet] = {}
40
+ self._agents: list[Agent] = []
41
+ self._contracts: list[Contract] = []
37
42
 
38
43
  @classmethod
39
- def from_dict(cls, definitions: dict, factory=FameIOFactory()) -> Scenario:
40
- """Parse scenario from provided `definitions` using given `factory`"""
41
- definitions = keys_to_lower(definitions)
44
+ def from_dict(cls, definitions: dict, factory: FameIOFactory = FameIOFactory()) -> Scenario:
45
+ """
46
+ Parse scenario from provided `definitions` using given `factory`
42
47
 
43
- schema = factory.new_schema_from_dict(get_or_raise(definitions, Scenario.KEY_SCHEMA, Scenario._MISSING_KEY))
44
- general_props = factory.new_general_properties_from_dict(
45
- get_or_raise(definitions, Scenario.KEY_GENERAL, Scenario._MISSING_KEY)
46
- )
47
- scenario = cls(schema, general_props)
48
- scenario._extract_metadata(definitions)
48
+ Args:
49
+ definitions: dictionary representation of scenario
50
+ factory: helper class with static helpers to instantiate scenario components
49
51
 
50
- for name, string_set_definition in get_or_default(definitions, Scenario.KEY_STRING_SETS, {}).items():
51
- scenario.add_string_set(name, factory.new_string_set_from_dict(string_set_definition))
52
+ Returns:
53
+ new Scenario
52
54
 
53
- for agent_definition in get_or_default(definitions, Scenario.KEY_AGENTS, []):
54
- scenario.add_agent(factory.new_agent_from_dict(agent_definition))
55
+ Raises:
56
+ ScenarioError: if scenario definitions are incomplete or erroneous, logged with level "ERROR"
57
+ """
58
+ definitions = keys_to_lower(definitions)
55
59
 
56
- for multi_contract_definition in get_or_default(definitions, Scenario.KEY_CONTRACTS, []):
57
- for single_contract_definition in Contract.split_contract_definitions(multi_contract_definition):
58
- scenario.add_contract(factory.new_contract_from_dict(single_contract_definition))
60
+ schema = Scenario._extract_schema(definitions, factory)
61
+ general_properties_definition = get_or_raise(definitions, Scenario.KEY_GENERAL, Scenario._MISSING_KEY)
62
+ general_properties = factory.new_general_properties_from_dict(general_properties_definition)
63
+ scenario = cls(schema, general_properties)
64
+ scenario._extract_metadata(definitions)
59
65
 
66
+ scenario._string_sets = Scenario._extract_string_sets(definitions, factory)
67
+ scenario._agents = [
68
+ factory.new_agent_from_dict(agent_definition)
69
+ for agent_definition in definitions.get(Scenario.KEY_AGENTS, [])
70
+ ]
71
+ scenario._contracts = Scenario._extract_contracts(definitions, factory)
60
72
  return scenario
61
73
 
74
+ @staticmethod
75
+ def _extract_schema(definitions: dict, factory: FameIOFactory) -> Schema:
76
+ """
77
+ Extract schema from given definitions and create Schema from it
78
+
79
+ Args:
80
+ definitions: dictionary representation of scenario
81
+ factory: helper class with static helpers to instantiate scenario components
82
+
83
+ Returns:
84
+ new schema
85
+
86
+ Raises:
87
+ ScenarioError: if schema definitions are missing, incomplete, or erroneous; logged on level "ERROR"
88
+ """
89
+ schema_definition = get_or_raise(definitions, Scenario.KEY_SCHEMA, Scenario._MISSING_KEY)
90
+ try:
91
+ return factory.new_schema_from_dict(schema_definition)
92
+ except SchemaError as e:
93
+ raise log_scenario_error(Scenario._ERR_SCHEMA) from e
94
+
95
+ @staticmethod
96
+ def _extract_string_sets(definitions: dict, factory: FameIOFactory) -> dict[str, StringSet]:
97
+ """
98
+ Extract string sets from given definitions and create dictionary from it
99
+
100
+ Args:
101
+ definitions: dictionary representation of scenario
102
+ factory: helper class with static helpers to instantiate scenario components
103
+
104
+ Returns:
105
+ dictionary of string set names associated with their corresponding string set
106
+
107
+ Raises:
108
+ ScenarioError: if string set definitions are incomplete or erroneous; logged on level "ERROR"
109
+ """
110
+ string_sets = {}
111
+ for name, string_set_definition in definitions.get(Scenario.KEY_STRING_SETS, {}).items():
112
+ try:
113
+ string_sets[name] = factory.new_string_set_from_dict(string_set_definition)
114
+ except StringSet.StringSetError as e:
115
+ raise log_scenario_error(Scenario._ERR_STRING_SET.format(name)) from e
116
+ return string_sets
117
+
118
+ @staticmethod
119
+ def _extract_contracts(definitions: dict, factory: FameIOFactory) -> list[Contract]:
120
+ """
121
+ Extract contracts from given definitions
122
+
123
+ Args:
124
+ definitions: dictionary representation of scenario
125
+ factory: helper class with static helpers to instantiate scenario components
126
+
127
+ Returns:
128
+ list of all created one-to-one contracts
129
+
130
+ Raises:
131
+ ScenarioError: if contract definitions are incomplete or erroneous; logged on level "ERROR"
132
+ """
133
+ contracts = []
134
+ for multi_contract_definition in definitions.get(Scenario.KEY_CONTRACTS, []):
135
+ try:
136
+ for single_contract_definition in Contract.split_contract_definitions(multi_contract_definition):
137
+ try:
138
+ contracts.append(factory.new_contract_from_dict(single_contract_definition))
139
+ except Contract.ContractError as e:
140
+ raise log_scenario_error(Scenario._ERR_CONTRACT.format(single_contract_definition)) from e
141
+ except Contract.ContractError as e:
142
+ raise log_scenario_error(Scenario._ERR_MULTI_CONTRACT.format(multi_contract_definition)) from e
143
+ return contracts
144
+
62
145
  def _to_dict(self) -> dict:
63
146
  """Serializes the scenario content to a dict"""
64
- result = {
147
+ result: dict[str, Any] = {
65
148
  Scenario.KEY_GENERAL: self.general_properties.to_dict(),
66
149
  Scenario.KEY_SCHEMA: self.schema.to_dict(),
67
150
  }
@@ -1,38 +1,57 @@
1
- # SPDX-FileCopyrightText: 2024 German Aerospace Center <fame@dlr.de>
1
+ # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
  from __future__ import annotations
5
5
 
6
- from typing import Union, Final
6
+ from typing import Final, Any, Union
7
7
 
8
+ from fameio.input import InputError
8
9
  from fameio.input.metadata import Metadata, MetadataComponent, ValueContainer
10
+ from fameio.logs import log_error
9
11
  from fameio.tools import keys_to_lower
10
- from .exception import log_and_raise
11
12
 
12
13
 
13
14
  class StringSet(Metadata):
14
15
  """Hosts a StringSet in the given format"""
15
16
 
17
+ class StringSetError(InputError):
18
+ """An error that occurred while parsing a StringSet definition"""
19
+
16
20
  KEY_VALUES: Final[str] = "Values".lower()
17
21
 
18
22
  ValueType = Union[list[str], dict[str, dict]]
19
23
  StringSetType = dict[str, Union[dict, ValueType]]
20
24
 
21
25
  _ERR_KEY_MISSING = "Missing mandatory key '{}' in StringSet definition {}."
26
+ _ERR_VALUE_DEFINITION = "StringSet could not be parsed."
22
27
 
23
- def __init__(self, definitions=None):
28
+ def __init__(self, definitions: dict[str, Any] | list[Any] | None = None):
24
29
  super().__init__(definitions)
25
30
  self._value_container: ValueContainer = ValueContainer(definitions)
26
31
 
27
32
  @classmethod
28
33
  def from_dict(cls, definition: StringSetType) -> StringSet:
29
- """Returns StringSet initialised from `definition`"""
34
+ """
35
+ Returns StringSet initialised from `definition`
36
+
37
+ Args:
38
+ definition: dictionary representation of string set
39
+
40
+ Returns:
41
+ new StringSet
42
+
43
+ Raises:
44
+ StringSetError: if definitions are incomplete or erroneous, logged on level "ERROR"
45
+ """
30
46
  string_set = cls(definition)
31
47
  definition = keys_to_lower(definition)
32
48
  if cls.KEY_VALUES in definition:
33
- string_set._value_container = ValueContainer(definition[cls.KEY_VALUES])
49
+ try:
50
+ string_set._value_container = ValueContainer(definition[cls.KEY_VALUES])
51
+ except ValueContainer.ParseError as e:
52
+ raise log_error(StringSet.StringSetError(StringSet._ERR_VALUE_DEFINITION)) from e
34
53
  else:
35
- log_and_raise(cls._ERR_KEY_MISSING.format(cls.KEY_VALUES, definition))
54
+ raise log_error(StringSet.StringSetError(cls._ERR_KEY_MISSING.format(cls.KEY_VALUES, definition)))
36
55
  return string_set
37
56
 
38
57
  def _to_dict(self) -> dict[str, dict[str, dict[str, dict[str, dict]]]]:
@@ -43,6 +62,6 @@ class StringSet(Metadata):
43
62
  """Returns values and their associated MetadataComponent"""
44
63
  return self._value_container.values
45
64
 
46
- def is_in_set(self, key: str) -> bool:
65
+ def is_in_set(self, key: Any) -> bool:
47
66
  """Returns True if `key` is a valid name in this StringSet"""
48
67
  return self._value_container.has_value(key)
@@ -1,8 +1,8 @@
1
- # SPDX-FileCopyrightText: 2024 German Aerospace Center <fame@dlr.de>
1
+ # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
 
5
- from .agenttype import AgentType
6
- from .attribute import AttributeSpecs, AttributeType
7
- from .java_packages import JavaPackages
8
- from .schema import Schema
5
+ from .agenttype import AgentType # noqa: F401
6
+ from .attribute import AttributeSpecs, AttributeType # noqa: F401
7
+ from .java_packages import JavaPackages # noqa: F401
8
+ from .schema import Schema # noqa: F401
@@ -1,4 +1,4 @@
1
- # SPDX-FileCopyrightText: 2024 German Aerospace Center <fame@dlr.de>
1
+ # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
4
  from __future__ import annotations
@@ -7,7 +7,7 @@ from typing import Any, Final
7
7
 
8
8
  from fameio.input import InputError, SchemaError
9
9
  from fameio.input.metadata import Metadata, MetadataComponent, ValueContainer
10
- from fameio.logs import log_error_and_raise, log
10
+ from fameio.logs import log, log_error
11
11
  from fameio.tools import keys_to_lower
12
12
  from .attribute import AttributeSpecs
13
13
 
@@ -32,11 +32,14 @@ class AgentType(Metadata):
32
32
  Initialise a new AgentType
33
33
 
34
34
  Args:
35
- name: name of the AgenType - must not be None, empty or only whitespaces
35
+ name: name of the AgenType
36
+
37
+ Raises:
38
+ SchemaError: if name is None, empty, or only whitespaces, logged with level "ERROR"
36
39
  """
37
40
  super().__init__()
38
41
  if not name or name.isspace():
39
- log_error_and_raise(SchemaError(AgentType._ERR_NAME_INVALID.format(name)))
42
+ raise log_error(SchemaError(AgentType._ERR_NAME_INVALID.format(name)))
40
43
  self._name = name
41
44
  self._attributes: dict[str, AttributeSpecs] = {}
42
45
  self._products: ValueContainer = ValueContainer()
@@ -53,6 +56,9 @@ class AgentType(Metadata):
53
56
 
54
57
  Returns:
55
58
  a new instance of AgentType
59
+
60
+ Raises:
61
+ SchemaError: if definitions are invalid, logged with level "ERROR"
56
62
  """
57
63
  agent_type = cls(name)
58
64
  agent_type._extract_metadata(definitions)
@@ -83,15 +89,27 @@ class AgentType(Metadata):
83
89
 
84
90
  @staticmethod
85
91
  def _read_values(section: str, agent_type: str, values: Any) -> ValueContainer:
86
- """Returns ValueContainer for `section` of in specifications of `agent_type` extracted from given `values`"""
92
+ """
93
+ Returns ValueContainer for `section` of in specifications of `agent_type` extracted from given `values`
94
+
95
+ Args:
96
+ section: key of the section that contains the values
97
+ agent_type: name of the agent type that the values are associated with
98
+ values: list or dict with value definitions
99
+
100
+ Returns:
101
+ container for all the extracted values
102
+
103
+ Raises:
104
+ SchemaError: if the values are ill-formatted, logged with level "ERROR"
105
+ """
87
106
  try:
88
107
  data = ValueContainer(values)
89
- except InputError:
90
- log_error_and_raise(SchemaError(AgentType._ERR_UNKNOWN_STRUCTURE.format(section, agent_type, values)))
91
- else:
92
- if not all([isinstance(item, str) for item in data.as_list()]):
93
- log_error_and_raise(SchemaError(AgentType._ERR_NO_STRING.format(section, agent_type, data.as_list())))
94
- return data
108
+ except InputError as e:
109
+ raise log_error(SchemaError(AgentType._ERR_UNKNOWN_STRUCTURE.format(section, agent_type, values))) from e
110
+ if not all(isinstance(item, str) for item in data.as_list()):
111
+ raise log_error(SchemaError(AgentType._ERR_NO_STRING.format(section, agent_type, data.as_list())))
112
+ return data
95
113
 
96
114
  @property
97
115
  def name(self) -> str: