fameio 3.4.0__py3-none-any.whl → 3.5.1__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 (70) hide show
  1. fameio/__init__.py +2 -1
  2. fameio/cli/__init__.py +2 -0
  3. fameio/cli/convert_results.py +8 -0
  4. fameio/cli/make_config.py +2 -0
  5. fameio/cli/options.py +4 -0
  6. fameio/cli/parser.py +17 -1
  7. fameio/cli/reformat.py +2 -0
  8. fameio/input/__init__.py +2 -1
  9. fameio/input/loader/__init__.py +1 -0
  10. fameio/input/loader/controller.py +20 -6
  11. fameio/input/loader/loader.py +2 -0
  12. fameio/input/metadata.py +2 -0
  13. fameio/input/resolver.py +2 -0
  14. fameio/input/scenario/__init__.py +2 -0
  15. fameio/input/scenario/agent.py +2 -0
  16. fameio/input/scenario/attribute.py +2 -0
  17. fameio/input/scenario/contract.py +2 -0
  18. fameio/input/scenario/exception.py +2 -0
  19. fameio/input/scenario/fameiofactory.py +2 -0
  20. fameio/input/scenario/generalproperties.py +2 -0
  21. fameio/input/scenario/scenario.py +5 -3
  22. fameio/input/scenario/stringset.py +2 -0
  23. fameio/input/schema/__init__.py +1 -0
  24. fameio/input/schema/agenttype.py +2 -0
  25. fameio/input/schema/attribute.py +2 -0
  26. fameio/input/schema/java_packages.py +2 -0
  27. fameio/input/schema/schema.py +8 -3
  28. fameio/input/validator.py +2 -0
  29. fameio/input/writer.py +16 -0
  30. fameio/logs.py +2 -1
  31. fameio/output/__init__.py +1 -0
  32. fameio/output/agent_type.py +24 -12
  33. fameio/output/conversion.py +2 -0
  34. fameio/output/csv_writer.py +10 -36
  35. fameio/output/data_transformer.py +2 -0
  36. fameio/output/execution_dao.py +5 -0
  37. fameio/output/files.py +55 -0
  38. fameio/output/input_dao.py +59 -15
  39. fameio/output/metadata/__init__.py +10 -0
  40. fameio/output/metadata/compiler.py +75 -0
  41. fameio/output/metadata/json_writer.py +36 -0
  42. fameio/output/metadata/locator.py +242 -0
  43. fameio/output/metadata/oeo_template.py +93 -0
  44. fameio/output/metadata/template_reader.py +65 -0
  45. fameio/output/output_dao.py +2 -0
  46. fameio/output/reader.py +1 -0
  47. fameio/output/yaml_writer.py +3 -1
  48. fameio/scripts/REUSE.toml +6 -0
  49. fameio/scripts/__init__.py +4 -0
  50. fameio/scripts/convert_results.py +46 -12
  51. fameio/scripts/exception.py +1 -0
  52. fameio/scripts/reformat.py +25 -1
  53. fameio/series.py +16 -7
  54. fameio/time.py +1 -0
  55. fameio/tools.py +1 -0
  56. fameio-3.5.1.dist-info/LICENSES/CC-BY-ND-4.0.txt +392 -0
  57. fameio-3.5.1.dist-info/METADATA +99 -0
  58. fameio-3.5.1.dist-info/RECORD +65 -0
  59. fameio/scripts/__init__.py.license +0 -3
  60. fameio/scripts/convert_results.py.license +0 -3
  61. fameio/scripts/make_config.py.license +0 -3
  62. fameio/scripts/reformat.py.license +0 -3
  63. fameio-3.4.0.dist-info/METADATA +0 -990
  64. fameio-3.4.0.dist-info/RECORD +0 -60
  65. {fameio-3.4.0.dist-info → fameio-3.5.1.dist-info}/LICENSE.txt +0 -0
  66. {fameio-3.4.0.dist-info → fameio-3.5.1.dist-info}/LICENSES/Apache-2.0.txt +0 -0
  67. {fameio-3.4.0.dist-info → fameio-3.5.1.dist-info}/LICENSES/CC-BY-4.0.txt +0 -0
  68. {fameio-3.4.0.dist-info → fameio-3.5.1.dist-info}/LICENSES/CC0-1.0.txt +0 -0
  69. {fameio-3.4.0.dist-info → fameio-3.5.1.dist-info}/WHEEL +0 -0
  70. {fameio-3.4.0.dist-info → fameio-3.5.1.dist-info}/entry_points.txt +0 -0
fameio/__init__.py CHANGED
@@ -1,6 +1,7 @@
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: CC0-1.0
4
+ """Source code for FAME-Io."""
4
5
 
5
6
  FILE_HEADER_V1 = "famecoreprotobufstreamfilev001" # noqa
6
7
  FILE_HEADER_V2 = "fameprotobufstreamfilev002 " # noqa
fameio/cli/__init__.py CHANGED
@@ -1,4 +1,6 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Parsing of the scripts' command line options."""
5
+
4
6
  from fameio.cli.parser import update_default_config # noqa: F401
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Static methods to handle command line arguments for the command that extracts protobuf files."""
5
+
4
6
  from __future__ import annotations
5
7
 
6
8
  import argparse
@@ -19,6 +21,8 @@ from fameio.cli.parser import (
19
21
  add_time_argument,
20
22
  add_merge_time_argument,
21
23
  add_inputs_recovery_argument,
24
+ add_output_metadata_argument,
25
+ add_output_template_argument,
22
26
  map_namespace_to_options_dict,
23
27
  )
24
28
 
@@ -34,6 +38,8 @@ CLI_DEFAULTS = {
34
38
  Options.TIME: TimeOptions.UTC,
35
39
  Options.TIME_MERGING: None,
36
40
  Options.INPUT_RECOVERY: False,
41
+ Options.METADATA: True,
42
+ Options.METADATA_TEMPLATE: None,
37
43
  }
38
44
 
39
45
  _INFILE_PATH_HELP = "Provide path to protobuf file"
@@ -75,6 +81,8 @@ def _prepare_parser(defaults: dict[Options, Any] | None) -> argparse.ArgumentPar
75
81
  add_time_argument(parser, _get_default(defaults, Options.TIME))
76
82
  add_merge_time_argument(parser, _get_default(defaults, Options.TIME_MERGING))
77
83
  add_inputs_recovery_argument(parser, _get_default(defaults, Options.INPUT_RECOVERY))
84
+ add_output_metadata_argument(parser, _get_default(defaults, Options.METADATA))
85
+ add_output_template_argument(parser, _get_default(defaults, Options.METADATA_TEMPLATE))
78
86
 
79
87
  return parser
80
88
 
fameio/cli/make_config.py CHANGED
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Static methods to handle command line arguments for the command that creates configuration files."""
5
+
4
6
  from __future__ import annotations
5
7
 
6
8
  import argparse
fameio/cli/options.py CHANGED
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Holds allowed command line arguments and value restrictions."""
5
+
4
6
  import argparse
5
7
  from enum import Enum, auto
6
8
 
@@ -36,6 +38,8 @@ class Options(Enum):
36
38
  INPUT_ENCODING = auto()
37
39
  FILE_PATTERN = auto()
38
40
  REPLACE = auto()
41
+ METADATA = auto()
42
+ METADATA_TEMPLATE = auto()
39
43
 
40
44
 
41
45
  class TimeOptions(ParsableEnum, Enum):
fameio/cli/parser.py CHANGED
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Methods to add individual command-line arguments to parsers."""
5
+
4
6
  from __future__ import annotations
5
7
 
6
8
  import copy
@@ -28,6 +30,8 @@ _OPTION_ARGUMENT_NAME: dict[str, Options] = {
28
30
  "merge_times": Options.TIME_MERGING,
29
31
  "file_pattern": Options.FILE_PATTERN,
30
32
  "replace": Options.REPLACE,
33
+ "metadata": Options.METADATA,
34
+ "template": Options.METADATA_TEMPLATE,
31
35
  }
32
36
 
33
37
 
@@ -168,7 +172,7 @@ def _add_optional_boolean_argument(parser: ArgumentParser, default: bool, arg_na
168
172
  Args:
169
173
  parser: to add the argument to
170
174
  default: of the argument
171
- arg_name: long name of the argument, no short name allowed; will be prepended with 'no-' for negation
175
+ arg_name: long name of the argument without '--', no short name allowed; prepends 'no-' for negation
172
176
  description: to create the help text from: "If --(no-)<arg_name> is specified, <description> (default=X)'
173
177
  """
174
178
  default_str = "--" + ("no-" if not default else "") + arg_name
@@ -189,6 +193,18 @@ def add_replace_argument(parser: ArgumentParser, default_value: bool) -> None:
189
193
  _add_optional_boolean_argument(parser, default_value, "replace", description)
190
194
 
191
195
 
196
+ def add_output_metadata_argument(parser: ArgumentParser, default_value: bool) -> None:
197
+ """Adds optional boolean argument to given `parser` to write output metadata."""
198
+ description = "metadata JSON file accompanying the output files are (not) written"
199
+ _add_optional_boolean_argument(parser, default_value, "metadata", description)
200
+
201
+
202
+ def add_output_template_argument(parser: ArgumentParser, default_value: Path | None) -> None:
203
+ """Adds optional argument to given `parser` to provide a metadata template."""
204
+ help_text = f"Path to metadata template file. Uses provided OEO template if not specified (default={default_value})"
205
+ parser.add_argument("-tmp", "--template", type=Path, help=help_text, required=False, default=default_value)
206
+
207
+
192
208
  def update_default_config(overrides: dict[Options, Any] | None, defaults: dict[Options, Any]) -> dict[Options, Any]:
193
209
  """Returns `defaults` with updated fields received from `overrides`.
194
210
 
fameio/cli/reformat.py CHANGED
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Static methods to handle command line arguments for the command that reformats time series files."""
5
+
4
6
  from __future__ import annotations
5
7
 
6
8
  import argparse
fameio/input/__init__.py CHANGED
@@ -1,6 +1,7 @@
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
+ """Classes and modules required for the compilation of FAME simulation input files in protobuf format."""
4
5
 
5
6
 
6
7
  class InputError(Exception):
@@ -1,6 +1,7 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Loading of YAML files that include custom commands."""
4
5
  from __future__ import annotations
5
6
 
6
7
  from pathlib import Path
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Holds the class that spawns the loaders for all YAML files to be read."""
5
+
4
6
  from __future__ import annotations
5
7
 
6
8
  from fnmatch import fnmatch
@@ -19,13 +21,17 @@ class LoaderController:
19
21
  """Controls loading of YAML files by spawning one FameYamlLoader per file.
20
22
 
21
23
  Uses same PathResolver and encoding for all files.
24
+
25
+ Attributes:
26
+ DISABLING_YAML_FILE_PREFIX: files starting with this string will be ignored
27
+ NODE_SPLIT_STRING: symbol that separates nodes in include patterns
22
28
  """
23
29
 
24
30
  DISABLING_YAML_FILE_PREFIX: Final[str] = "IGNORE_"
25
31
  NODE_SPLIT_STRING: Final[str] = ":"
26
32
 
27
33
  _ERR_FILE_OPEN_ERROR = "Could not open file: '{}'"
28
- _ERR_FILE_LOAD_ERROR = "Could not parse YAML file due to errors in (line:column): ({}:{})"
34
+ _ERR_FILE_LOAD_ERROR = "Could not parse file '{}' due to error in (line:column): ({}:{})"
29
35
  _ERR_NODE_MISSING = "'!include_node [{}, {}]': Cannot find '{}'"
30
36
  _ERR_NOT_LIST = "!include can only combine list-like elements from multiple files!"
31
37
  _WARN_NOTHING_TO_INCLUDE = "Could not find any files matching this '!include' directive '{}'"
@@ -36,14 +42,20 @@ class LoaderController:
36
42
  _DEBUG_FILES_INCLUDED = "!include directive '{}' yielded these files: '{}'"
37
43
 
38
44
  def __init__(self, path_resolver: PathResolver = PathResolver(), encoding: str | None = None) -> None:
45
+ """Instantiate a new LoaderController.
46
+
47
+ Args:
48
+ path_resolver: to resolve paths to files that are to be included
49
+ encoding: to use when reading the file
50
+ """
39
51
  self._path_resolver = path_resolver
40
52
  self._encoding: str | None = encoding
41
53
 
42
- def load(self, yaml_file_path: Path) -> dict:
54
+ def load(self, file_path: Path) -> dict:
43
55
  """Spawns a new FameYamlLoader, loads the given `yaml_file_path` and returns its content.
44
56
 
45
57
  Args:
46
- yaml_file_path: path to YAML file that is to be loaded
58
+ file_path: path to YAML file that is to be loaded
47
59
 
48
60
  Returns:
49
61
  dictionary representation of loaded file
@@ -52,14 +64,16 @@ class LoaderController:
52
64
  YamlLoaderError: if file could not be read, logged with level "CRITICAL"
53
65
  """
54
66
  try:
55
- with open(yaml_file_path, "r", encoding=self._encoding) as configfile:
67
+ with open(file_path, "r", encoding=self._encoding) as configfile:
56
68
  try:
57
69
  data = yaml.load(configfile, self._spawn_loader_builder()) # type: ignore[arg-type]
58
70
  except yaml.YAMLError as e:
59
71
  line, column = self._get_problem_position(e)
60
- raise log_critical(YamlLoaderError(self._ERR_FILE_LOAD_ERROR.format(line, column))) from e
72
+ raise log_critical(
73
+ YamlLoaderError(self._ERR_FILE_LOAD_ERROR.format(file_path, line, column))
74
+ ) from e
61
75
  except OSError as e:
62
- raise log_critical(YamlLoaderError(self._ERR_FILE_OPEN_ERROR.format(yaml_file_path))) from e
76
+ raise log_critical(YamlLoaderError(self._ERR_FILE_OPEN_ERROR.format(file_path))) from e
63
77
  return data
64
78
 
65
79
  @staticmethod
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Holds the class that loads a YAML file supporting custom commands."""
5
+
4
6
  from os import path
5
7
  from typing import IO, Final
6
8
 
fameio/input/metadata.py CHANGED
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Storing Metadata associated with inputs, outputs, or models."""
5
+
4
6
  from __future__ import annotations
5
7
 
6
8
  from abc import ABC, abstractmethod
fameio/input/resolver.py CHANGED
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Resolving of file paths."""
5
+
4
6
  from __future__ import annotations
5
7
 
6
8
  import glob
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Classes to load, represent, modify, and save scenarios and their components."""
5
+
4
6
  from .agent import Agent # noqa: F401
5
7
  from .attribute import Attribute # noqa: F401
6
8
  from .contract import Contract # noqa: F401
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Holds the class that represents agents of scenarios."""
5
+
4
6
  from __future__ import annotations
5
7
 
6
8
  import ast
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Holds the class that represents agent attributes in scenarios."""
5
+
4
6
  from __future__ import annotations
5
7
 
6
8
  from enum import Enum, auto
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Holds the class that represents contracts in scenarios."""
5
+
4
6
  from __future__ import annotations
5
7
 
6
8
  from typing import Any, Final, overload
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Holds static methods to create or log exceptions."""
5
+
4
6
  from __future__ import annotations
5
7
 
6
8
  from typing import Any
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Holds a class that helps to create scenario."""
5
+
4
6
  from fameio.input.schema import Schema
5
7
  from .agent import Agent
6
8
  from .contract import Contract
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Holds a class to describe the general properties of a simulation."""
5
+
4
6
  from __future__ import annotations
5
7
 
6
8
  from typing import Final
@@ -1,9 +1,11 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Holds a class to describe scenarios."""
5
+
4
6
  from __future__ import annotations
5
7
 
6
- from typing import Final, Any
8
+ from typing import Final, Any, Optional
7
9
 
8
10
  from fameio.input import SchemaError
9
11
  from fameio.input.metadata import Metadata
@@ -32,8 +34,8 @@ class Scenario(Metadata):
32
34
  _ERR_MULTI_CONTRACT = "Could not create scenario: Definition of Contracts has errors: {}"
33
35
  _ERR_CONTRACT = "Could not create scenario: Definition of Contract has errors: {}"
34
36
 
35
- def __init__(self, schema: Schema, general_props: GeneralProperties) -> None:
36
- super().__init__()
37
+ def __init__(self, schema: Schema, general_props: GeneralProperties, metadata: Optional[dict] = None) -> None:
38
+ super().__init__({Metadata.KEY_METADATA: metadata})
37
39
  self._schema = schema
38
40
  self._general_props = general_props
39
41
  self._string_sets: dict[str, StringSet] = {}
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Holds a class to describe StringSets."""
5
+
4
6
  from __future__ import annotations
5
7
 
6
8
  from typing import Final, Any, Union
@@ -1,6 +1,7 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Classes to load, represent, and save schemas and their components."""
4
5
 
5
6
  from .agenttype import AgentType # noqa: F401
6
7
  from .attribute import AttributeSpecs, AttributeType # noqa: F401
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Hold a class to describe a type of agent."""
5
+
4
6
  from __future__ import annotations
5
7
 
6
8
  from typing import Any, Final
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Holds classes to describe an attribute of an agent."""
5
+
4
6
  from __future__ import annotations
5
7
 
6
8
  from enum import Enum, auto
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Holds the class to describe the names of java packages that contain the model."""
5
+
4
6
  from __future__ import annotations
5
7
 
6
8
  from typing import Final
@@ -1,19 +1,23 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Holds the basic schema class."""
5
+
4
6
  from __future__ import annotations
5
7
 
6
8
  import ast
9
+ from copy import deepcopy
7
10
  from typing import Any, Final
8
11
 
9
12
  from fameio.input import SchemaError
13
+ from fameio.input.metadata import Metadata
10
14
  from fameio.logs import log_error
11
15
  from fameio.tools import keys_to_lower
12
16
  from .agenttype import AgentType
13
17
  from .java_packages import JavaPackages
14
18
 
15
19
 
16
- class Schema:
20
+ class Schema(Metadata):
17
21
  """Definition of a schema."""
18
22
 
19
23
  KEY_AGENT_TYPE: Final[str] = "AgentTypes".lower()
@@ -24,7 +28,8 @@ class Schema:
24
28
  _ERR_MISSING_PACKAGES = "Missing required section `JavaPackages` in Schema."
25
29
 
26
30
  def __init__(self, definitions: dict) -> None:
27
- self._original_input_dict = definitions
31
+ super().__init__(definitions)
32
+ self._original_input_dict = deepcopy(definitions)
28
33
  self._agent_types: dict[str, AgentType] = {}
29
34
  self._packages: JavaPackages | None = None
30
35
 
@@ -80,7 +85,7 @@ class Schema:
80
85
  """Load given string `definitions` into a new Schema."""
81
86
  return cls.from_dict(ast.literal_eval(definitions))
82
87
 
83
- def to_dict(self) -> dict:
88
+ def _to_dict(self) -> dict:
84
89
  """Serializes the schema content to a dict."""
85
90
  return self._original_input_dict
86
91
 
fameio/input/validator.py CHANGED
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Checking scenarios for consistency with their model schema."""
5
+
4
6
  from __future__ import annotations
5
7
 
6
8
  import math
fameio/input/writer.py CHANGED
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Writing simulation configuration files in protobuf format."""
5
+
4
6
  from __future__ import annotations
5
7
 
6
8
  import sys
@@ -88,6 +90,7 @@ class ProtoWriter:
88
90
  self._set_time_series(pb_input)
89
91
  self._set_schema(pb_input, scenario.schema)
90
92
  self._set_string_sets(pb_input, scenario.string_sets)
93
+ self._set_scenario_metadata(pb_input, scenario.metadata)
91
94
 
92
95
  self._set_java_package_names(pb_data_storage.model, scenario.schema.packages)
93
96
  self._set_execution_versions(pb_data_storage.execution.version_data)
@@ -146,6 +149,7 @@ class ProtoWriter:
146
149
  values_not_set = list(specs.keys())
147
150
  for name, attribute in attributes.items():
148
151
  pb_field = self._add_field(pb_parent, name)
152
+ self._set_field_metadata(pb_field, attribute.metadata)
149
153
  attribute_specs = specs[name]
150
154
  values_not_set.remove(name)
151
155
  attribute_type = attribute_specs.attr_type
@@ -172,6 +176,12 @@ class ProtoWriter:
172
176
  pb_field.field_name = name
173
177
  return pb_field
174
178
 
179
+ @staticmethod
180
+ def _set_field_metadata(pb_field: NestedField, attribute_metadata: dict) -> None:
181
+ """Sets metadata of given `pb_field`, provided that given `attribute_metadata` are not empty"""
182
+ if attribute_metadata:
183
+ pb_field.metadata = repr(attribute_metadata)
184
+
175
185
  def _set_attribute(self, pb_field: NestedField, value: Any, attribute_type: AttributeType) -> None:
176
186
  """Sets given `value` to given protobuf `pb_field` depending on specified `attribute_type`.
177
187
 
@@ -285,6 +295,12 @@ class ProtoWriter:
285
295
  if string_set.has_metadata():
286
296
  pb_set.metadata = string_set.get_metadata_string()
287
297
 
298
+ @staticmethod
299
+ def _set_scenario_metadata(pb_input: InputData, scenario_metadata: dict) -> None:
300
+ """Adds the given metadata to the provided `pb_input.`"""
301
+ if scenario_metadata:
302
+ pb_input.metadata = repr(scenario_metadata)
303
+
288
304
  @staticmethod
289
305
  def _set_java_package_names(pb_model: ModelData, java_packages: JavaPackages) -> None:
290
306
  """Adds given JavaPackages names to given ModelData section."""
fameio/logs.py CHANGED
@@ -1,6 +1,7 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Handling of fameio-specific logger, log levels, and log formatting."""
4
5
  from __future__ import annotations
5
6
 
6
7
  import logging as pylog
@@ -49,7 +50,7 @@ def log_critical(exception: T) -> T:
49
50
  """Logs a critical error with the exception's message and returns the exception for raising it.
50
51
 
51
52
  Does **not** raise the exception, i.e. the command must be preceded by a `raise`.
52
- Example: `raise log_critical(MyException("My error message"))
53
+ Example: `raise log_critical(MyException("My error message"))`
53
54
 
54
55
  Args:
55
56
  exception: to extract the error message from
fameio/output/__init__.py CHANGED
@@ -1,6 +1,7 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: CC0-1.0
4
+ """Classes and modules required for the transformation of protobuf files to human-readable file formats."""
4
5
 
5
6
 
6
7
  class OutputError(Exception):
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Description of types of agents and their output data."""
5
+
4
6
  from __future__ import annotations
5
7
 
6
8
  from fameprotobuf.services_pb2 import Output
@@ -75,24 +77,22 @@ class AgentTypeLog:
75
77
  self._agents_with_output: list[str] = []
76
78
 
77
79
  def update_agents(self, new_types: dict[str, Output.AgentType]) -> None:
78
- """Saves `new_types` if they are requested for extraction.
80
+ """Saves new types of agents for later inspection.
79
81
 
80
- If any new agent types are provided, checks if they are requested for extraction, and, if so, saves them.
81
- Agent types not requested for extraction are ignored.
82
+ If any new agent types are provided, registers them as "agents with output"
83
+ Then, checks if they are requested for extraction, and, if so, saves them as "requested agent types".
82
84
 
83
85
  Args:
84
- new_types: to be saved (if requested for extraction)
86
+ new_types: to be logged
85
87
 
86
88
  Raises:
87
89
  AgentTypeError: if agent type was already registered, logged with level "ERROR"
88
90
  """
89
- if not new_types:
90
- return
91
-
92
- self._agents_with_output.extend(list(new_types.keys()))
93
- filtered_types = self._filter_agents_by_name(new_types)
94
- self._ensure_no_duplication(filtered_types)
95
- self._requested_agent_types.update(filtered_types)
91
+ if new_types is not None and len(new_types) > 0:
92
+ self._agents_with_output.extend(list(new_types.keys()))
93
+ filtered_types = self._filter_agents_by_name(new_types)
94
+ self._ensure_no_duplication(filtered_types)
95
+ self._requested_agent_types.update(filtered_types)
96
96
 
97
97
  def _filter_agents_by_name(self, new_types: dict[str, Output.AgentType]) -> dict[str, Output.AgentType]:
98
98
  """Removes and entries from `new_types` not on `agent_name_filter_list`.
@@ -125,7 +125,7 @@ class AgentTypeLog:
125
125
  raise log_error(AgentTypeError(self._ERR_DOUBLE_DEFINITION.format(agent_name)))
126
126
 
127
127
  def has_any_agent_type(self) -> bool:
128
- """Returns True if any agent type was registered so far present."""
128
+ """Returns True if any agent type was registered so far."""
129
129
  return len(self._requested_agent_types) > 0
130
130
 
131
131
  def get_agent_type(self, agent_type_name: str) -> AgentType:
@@ -151,3 +151,15 @@ class AgentTypeLog:
151
151
  def get_agents_with_output(self) -> list[str]:
152
152
  """Returns all names of agents that had output."""
153
153
  return self._agents_with_output
154
+
155
+ def get_agent_columns(self) -> dict[str, list[str]]:
156
+ """Returns all agents that were not filtered, with their output mapped to their simple output columns.
157
+
158
+ Raises:
159
+ AgentTypeError: if - somehow - an agent type is not registered but has data, logged with level "ERROR"
160
+ """
161
+ result = {}
162
+ for agent_name in self._requested_agent_types:
163
+ agent_type = self.get_agent_type(agent_name)
164
+ result[agent_name] = list(agent_type.get_simple_column_map().values())
165
+ return result
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2025 German Aerospace Center <fame@dlr.de>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ """Methods to convert or merge time stamps of agent timeseries output."""
5
+
4
6
  from __future__ import annotations
5
7
 
6
8
  import math