fameio 1.8.1__py3-none-any.whl → 2.0.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.
- CHANGELOG.md +204 -0
- fameio/scripts/__init__.py +8 -6
- fameio/scripts/__init__.py.license +3 -0
- fameio/scripts/convert_results.py +30 -34
- fameio/scripts/convert_results.py.license +3 -0
- fameio/scripts/make_config.py +13 -16
- fameio/scripts/make_config.py.license +3 -0
- fameio/source/cli/__init__.py +3 -0
- fameio/source/cli/convert_results.py +75 -0
- fameio/source/cli/make_config.py +62 -0
- fameio/source/cli/options.py +59 -0
- fameio/source/cli/parser.py +238 -0
- fameio/source/loader.py +10 -11
- fameio/source/logs.py +49 -25
- fameio/source/results/conversion.py +12 -14
- fameio/source/results/csv_writer.py +16 -5
- fameio/source/results/data_transformer.py +3 -2
- fameio/source/results/input_dao.py +163 -0
- fameio/source/results/reader.py +25 -14
- fameio/source/results/yaml_writer.py +28 -0
- fameio/source/scenario/agent.py +56 -39
- fameio/source/scenario/attribute.py +9 -12
- fameio/source/scenario/contract.py +55 -40
- fameio/source/scenario/exception.py +11 -9
- fameio/source/scenario/generalproperties.py +11 -17
- fameio/source/scenario/scenario.py +19 -14
- fameio/source/schema/agenttype.py +75 -27
- fameio/source/schema/attribute.py +8 -7
- fameio/source/schema/schema.py +24 -11
- fameio/source/series.py +146 -25
- fameio/source/time.py +8 -8
- fameio/source/tools.py +13 -2
- fameio/source/validator.py +138 -58
- fameio/source/writer.py +108 -112
- fameio-2.0.0.dist-info/LICENSES/Apache-2.0.txt +178 -0
- fameio-2.0.0.dist-info/LICENSES/CC-BY-4.0.txt +395 -0
- fameio-2.0.0.dist-info/LICENSES/CC0-1.0.txt +121 -0
- {fameio-1.8.1.dist-info → fameio-2.0.0.dist-info}/METADATA +144 -112
- fameio-2.0.0.dist-info/RECORD +52 -0
- {fameio-1.8.1.dist-info → fameio-2.0.0.dist-info}/WHEEL +1 -2
- fameio-2.0.0.dist-info/entry_points.txt +4 -0
- fameio/source/cli.py +0 -253
- fameio-1.8.1.dist-info/RECORD +0 -40
- fameio-1.8.1.dist-info/entry_points.txt +0 -3
- fameio-1.8.1.dist-info/top_level.txt +0 -1
- {fameio-1.8.1.dist-info → fameio-2.0.0.dist-info}/LICENSE.txt +0 -0
fameio/source/cli.py
DELETED
@@ -1,253 +0,0 @@
|
|
1
|
-
# SPDX-FileCopyrightText: 2023 German Aerospace Center <fame@dlr.de>
|
2
|
-
#
|
3
|
-
# SPDX-License-Identifier: Apache-2.0
|
4
|
-
|
5
|
-
import argparse
|
6
|
-
import copy
|
7
|
-
from enum import Enum, auto
|
8
|
-
from pathlib import Path
|
9
|
-
from typing import Optional, Dict, Any, List, Tuple
|
10
|
-
|
11
|
-
from fameio.source.logs import LOG_LEVELS
|
12
|
-
|
13
|
-
ERR_NEGATIVE_INT = "Given value `{}` is not a non-negative int."
|
14
|
-
|
15
|
-
|
16
|
-
class Options(Enum):
|
17
|
-
"""Specifies command line configuration options"""
|
18
|
-
|
19
|
-
FILE = auto()
|
20
|
-
LOG_LEVEL = auto()
|
21
|
-
LOG_FILE = auto()
|
22
|
-
OUTPUT = auto()
|
23
|
-
AGENT_LIST = auto()
|
24
|
-
SINGLE_AGENT_EXPORT = auto()
|
25
|
-
MEMORY_SAVING = auto()
|
26
|
-
RESOLVE_COMPLEX_FIELD = auto()
|
27
|
-
TIME = auto()
|
28
|
-
TIME_MERGING = auto()
|
29
|
-
|
30
|
-
|
31
|
-
class TimeOptions(Enum):
|
32
|
-
"""Specifies options for conversion of time in output"""
|
33
|
-
|
34
|
-
INT = auto()
|
35
|
-
UTC = auto()
|
36
|
-
FAME = auto()
|
37
|
-
|
38
|
-
|
39
|
-
class ResolveOptions(Enum):
|
40
|
-
"""Specifies options for resolving complex fields in output files"""
|
41
|
-
|
42
|
-
IGNORE = auto()
|
43
|
-
SPLIT = auto()
|
44
|
-
MERGE = auto()
|
45
|
-
|
46
|
-
|
47
|
-
class MergingOptions(Enum):
|
48
|
-
"""Specifies options for merging TimeSteps"""
|
49
|
-
|
50
|
-
FOCAL_POINT = auto()
|
51
|
-
STEPS_BEFORE = auto()
|
52
|
-
STEPS_AFTER = auto()
|
53
|
-
|
54
|
-
|
55
|
-
def arg_handling_make_config(args: List[str], defaults: Dict) -> Tuple[str, Dict]:
|
56
|
-
"""Handles command line arguments and returns `input_file` and `run_config` for make_config script"""
|
57
|
-
parser = argparse.ArgumentParser()
|
58
|
-
|
59
|
-
add_file_argument(parser, "provide path to configuration file")
|
60
|
-
add_log_level_argument(parser, defaults[Options.LOG_LEVEL])
|
61
|
-
add_logfile_argument(parser)
|
62
|
-
add_output_argument(parser, defaults[Options.OUTPUT], "provide file-path for the file to generate")
|
63
|
-
|
64
|
-
args = parser.parse_args(args)
|
65
|
-
run_config = {
|
66
|
-
Options.LOG_LEVEL: args.log,
|
67
|
-
Options.LOG_FILE: args.logfile,
|
68
|
-
Options.OUTPUT: args.output,
|
69
|
-
}
|
70
|
-
return args.file, run_config
|
71
|
-
|
72
|
-
|
73
|
-
def arg_handling_convert_results(args: List[str], defaults: Dict) -> Tuple[str, Dict]:
|
74
|
-
"""Handles command line arguments and returns `input_file` and `run_config` for convert_results script"""
|
75
|
-
parser = argparse.ArgumentParser()
|
76
|
-
|
77
|
-
add_file_argument(parser, "provide path to protobuf file")
|
78
|
-
add_log_level_argument(parser, defaults[Options.LOG_LEVEL])
|
79
|
-
add_logfile_argument(parser)
|
80
|
-
add_output_argument(
|
81
|
-
parser,
|
82
|
-
defaults[Options.OUTPUT],
|
83
|
-
"provide path to folder to store output .csv files",
|
84
|
-
)
|
85
|
-
add_select_agents_argument(parser)
|
86
|
-
add_single_export_argument(parser, defaults[Options.SINGLE_AGENT_EXPORT])
|
87
|
-
add_memory_saving_argument(parser, defaults[Options.MEMORY_SAVING])
|
88
|
-
add_resolve_complex_argument(parser, defaults[Options.RESOLVE_COMPLEX_FIELD])
|
89
|
-
add_time_argument(parser, defaults[Options.TIME])
|
90
|
-
add_merge_time_parser(parser)
|
91
|
-
|
92
|
-
args = parser.parse_args(args)
|
93
|
-
|
94
|
-
run_config = {
|
95
|
-
Options.LOG_LEVEL: args.log,
|
96
|
-
Options.LOG_FILE: args.logfile,
|
97
|
-
Options.OUTPUT: args.output,
|
98
|
-
Options.AGENT_LIST: args.agents,
|
99
|
-
Options.SINGLE_AGENT_EXPORT: args.single_export,
|
100
|
-
Options.MEMORY_SAVING: args.memory_saving,
|
101
|
-
Options.RESOLVE_COMPLEX_FIELD: ResolveOptions[args.complex_column],
|
102
|
-
Options.TIME: args.time,
|
103
|
-
Options.TIME_MERGING: get_merging_args(args),
|
104
|
-
}
|
105
|
-
return args.file, run_config
|
106
|
-
|
107
|
-
|
108
|
-
def add_file_argument(parser: argparse.ArgumentParser, help_text: str) -> None:
|
109
|
-
"""Adds required 'file' argument to the provided `parser` with the provided `help_text`"""
|
110
|
-
parser.add_argument("-f", "--file", type=Path, required=True, help=help_text)
|
111
|
-
|
112
|
-
|
113
|
-
def add_select_agents_argument(parser: argparse.ArgumentParser) -> None:
|
114
|
-
"""Adds optional repeatable string argument 'agent' to given `parser`"""
|
115
|
-
help_text = "Provide list of agents to extract (default=None)"
|
116
|
-
parser.add_argument("-a", "--agents", nargs="*", type=str, help=help_text)
|
117
|
-
|
118
|
-
|
119
|
-
def add_logfile_argument(parser: argparse.ArgumentParser) -> None:
|
120
|
-
"""Adds optional argument 'logfile' to given `parser`"""
|
121
|
-
help_text = "provide logging file (default=None)"
|
122
|
-
parser.add_argument("-lf", "--logfile", type=Path, help=help_text)
|
123
|
-
|
124
|
-
|
125
|
-
def add_output_argument(parser: argparse.ArgumentParser, default_value, help_text: str) -> None:
|
126
|
-
"""Adds optional argument 'output' to given `parser` using the given `help_text` and `default_value`"""
|
127
|
-
parser.add_argument("-o", "--output", type=Path, default=default_value, help=help_text)
|
128
|
-
|
129
|
-
|
130
|
-
def add_log_level_argument(parser: argparse.ArgumentParser, default_value: str) -> None:
|
131
|
-
"""Adds optional argument 'log' to given `parser`"""
|
132
|
-
help_text = "choose logging level (default: {})".format(default_value)
|
133
|
-
parser.add_argument(
|
134
|
-
"-l",
|
135
|
-
"--log",
|
136
|
-
default=default_value,
|
137
|
-
choices=list(LOG_LEVELS.keys()),
|
138
|
-
type=str.lower,
|
139
|
-
help=help_text,
|
140
|
-
)
|
141
|
-
|
142
|
-
|
143
|
-
def add_single_export_argument(parser: argparse.ArgumentParser, default_value: bool) -> None:
|
144
|
-
"""Adds optional repeatable string argument 'agent' to given `parser`"""
|
145
|
-
help_text = "Enable export of single agents (default=False)"
|
146
|
-
parser.add_argument(
|
147
|
-
"-se",
|
148
|
-
"--single-export",
|
149
|
-
default=default_value,
|
150
|
-
action="store_true",
|
151
|
-
help=help_text,
|
152
|
-
)
|
153
|
-
|
154
|
-
|
155
|
-
def add_memory_saving_argument(parser: argparse.ArgumentParser, default_value: bool) -> None:
|
156
|
-
"""Adds optional bool argument to given `parser` to enable memory saving mode"""
|
157
|
-
help_text = "Reduces memory usage profile at the cost of runtime (default=False)"
|
158
|
-
parser.add_argument(
|
159
|
-
"-m",
|
160
|
-
"--memory-saving",
|
161
|
-
default=default_value,
|
162
|
-
action="store_true",
|
163
|
-
help=help_text,
|
164
|
-
)
|
165
|
-
|
166
|
-
|
167
|
-
def add_resolve_complex_argument(parser, default_value: str):
|
168
|
-
"""Instructs given `parser` how to deal with complex field outputs"""
|
169
|
-
help_text = f"How to deal with complex index columns? (default={default_value})"
|
170
|
-
parser.add_argument(
|
171
|
-
"-cc",
|
172
|
-
"--complex-column",
|
173
|
-
default=default_value,
|
174
|
-
choices=[e.name for e in ResolveOptions],
|
175
|
-
help=help_text,
|
176
|
-
type=str.upper,
|
177
|
-
)
|
178
|
-
|
179
|
-
|
180
|
-
def add_time_argument(parser: argparse.ArgumentParser, default_value: str) -> None:
|
181
|
-
"""Adds optional argument to given `parser` to define conversion of TimeSteps"""
|
182
|
-
help_text = "Apply conversion of time steps to given format (default=UTC)"
|
183
|
-
parser.add_argument(
|
184
|
-
"-t", "--time", default=default_value, choices=[e.name for e in TimeOptions], help=help_text, type=str.upper
|
185
|
-
)
|
186
|
-
|
187
|
-
|
188
|
-
def add_merge_time_parser(parser: argparse.ArgumentParser) -> None:
|
189
|
-
"""Adds subparser for merging of TimeSteps to given `parser`"""
|
190
|
-
subparser = parser.add_subparsers(dest="time_merging", required=False, help="Optional merging of TimeSteps")
|
191
|
-
group_parser = subparser.add_parser("merge-times")
|
192
|
-
add_focal_point_argument(group_parser)
|
193
|
-
add_steps_before_argument(group_parser)
|
194
|
-
add_steps_after_argument(group_parser)
|
195
|
-
|
196
|
-
|
197
|
-
def add_focal_point_argument(parser: argparse.ArgumentParser) -> None:
|
198
|
-
"""Adds `focal-point` argument to given `parser`"""
|
199
|
-
help_text = "TimeStep on which `steps_before` earlier and `steps_after` later TimeSteps are merged on"
|
200
|
-
parser.add_argument("-fp", "--focal-point", required=True, type=int, help=help_text)
|
201
|
-
|
202
|
-
|
203
|
-
def add_steps_before_argument(parser: argparse.ArgumentParser) -> None:
|
204
|
-
"""Adds `steps-before` argument to given `parser`"""
|
205
|
-
help_text = "Range of TimeSteps before the `focal-point` they get merged to"
|
206
|
-
parser.add_argument("-sb", "--steps-before", required=True, type=non_negative_int, help=help_text)
|
207
|
-
|
208
|
-
|
209
|
-
def non_negative_int(value: Any) -> int:
|
210
|
-
"""
|
211
|
-
Casts a given ´value` to int and checks it for non-negativity
|
212
|
-
|
213
|
-
Args:
|
214
|
-
value: to check and parse
|
215
|
-
|
216
|
-
Returns:
|
217
|
-
`value` parsed to int if it is a non-negative integer
|
218
|
-
|
219
|
-
Raises:
|
220
|
-
TypeError: if `value` is None
|
221
|
-
ValueError: if `value` cannot be parsed to int
|
222
|
-
argparse.ArgumentTypeError: if `value` is a negative int
|
223
|
-
|
224
|
-
"""
|
225
|
-
value = int(value)
|
226
|
-
if value < 0:
|
227
|
-
raise argparse.ArgumentTypeError(ERR_NEGATIVE_INT.format(value))
|
228
|
-
return value
|
229
|
-
|
230
|
-
|
231
|
-
def add_steps_after_argument(parser: argparse.ArgumentParser) -> None:
|
232
|
-
"""Adds `steps-after` argument to given `parser`"""
|
233
|
-
help_text = "Range of TimeSteps after the `focal-point` they get merged to"
|
234
|
-
parser.add_argument("-sa", "--steps-after", required=True, type=non_negative_int, help=help_text)
|
235
|
-
|
236
|
-
|
237
|
-
def get_merging_args(args: argparse.Namespace) -> Dict[MergingOptions, int]:
|
238
|
-
"""Returns a dictionary of GroupingOptions with their values if `time_merging` entry exists"""
|
239
|
-
merging_args = {}
|
240
|
-
if vars(args).get("time_merging"):
|
241
|
-
merging_args[MergingOptions.FOCAL_POINT] = args.focal_point
|
242
|
-
merging_args[MergingOptions.STEPS_BEFORE] = args.steps_before
|
243
|
-
merging_args[MergingOptions.STEPS_AFTER] = args.steps_after
|
244
|
-
return merging_args
|
245
|
-
|
246
|
-
|
247
|
-
def update_default_config(config: Optional[dict], default: dict) -> dict:
|
248
|
-
"""Returns `default` config with updated fields received from `config`"""
|
249
|
-
result = copy.deepcopy(default)
|
250
|
-
if config:
|
251
|
-
for name, option in config.items():
|
252
|
-
result[name] = option
|
253
|
-
return result
|
fameio-1.8.1.dist-info/RECORD
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
fameio/__init__.py,sha256=IQm0MNOXkhBexiMXBoNZDK5xHUYgazH7oXm-lc0Vm04,109
|
2
|
-
fameio/scripts/__init__.py,sha256=9WB1NgbuF-CoBLL_FhWJMtEAO7hUV6GUM_Grx3Y4OL8,746
|
3
|
-
fameio/scripts/convert_results.py,sha256=LKqSP-jG0rEf4jK3eRxkOXOtYNo1c-WvbkYS5rXyE18,3296
|
4
|
-
fameio/scripts/make_config.py,sha256=F2cmYNmWtLbLO-bHS6i8YlBtZ67JPXaKEPkiblX-QqU,1339
|
5
|
-
fameio/source/__init__.py,sha256=14CnWOIkdSeKQg6FioQSgO7UtEFF6pO4MUtDAUfwNmA,278
|
6
|
-
fameio/source/cli.py,sha256=UuIrC3cB-HehuoQwwjsVn86qdNdqSL5m0jmyiboKdtc,9384
|
7
|
-
fameio/source/loader.py,sha256=Ol_Q83OD2HeSPD3lX8XP3bGHef-E7YvCXGEspddoAyA,7403
|
8
|
-
fameio/source/logs.py,sha256=lO11JHAl6iWr_d6-ETD_IVwkeL__ZIhi27wSvSuWKnI,1929
|
9
|
-
fameio/source/path_resolver.py,sha256=cIEVvz7Eh4e3Rh87XkwyGiyj9iKxUI7TzWtq6ClhLd8,1321
|
10
|
-
fameio/source/series.py,sha256=BgJLmxGGzrZmWjXMYrUcj53-y3VwV8PbAaqsa1TuiRQ,1924
|
11
|
-
fameio/source/time.py,sha256=TCcGl0BYVJztiptqh8uagIvYEUlKbY9FMtkxnPYM884,6943
|
12
|
-
fameio/source/tools.py,sha256=SyR1VoWRos64zp7zieQ9JWnB3qP9Zh2Ig-VI9J9w5Pw,630
|
13
|
-
fameio/source/validator.py,sha256=hSKogx2mQpIDlIZdi5OEa9h39dOqL9rzNW4wJS6imgE,11409
|
14
|
-
fameio/source/writer.py,sha256=HqRbNOwHK-367sOi3sA1JP3ZHCS6te55Fk9T9FjlSyc,11633
|
15
|
-
fameio/source/results/__init__.py,sha256=IQm0MNOXkhBexiMXBoNZDK5xHUYgazH7oXm-lc0Vm04,109
|
16
|
-
fameio/source/results/agent_type.py,sha256=pW5cLduLlNOcBBvS6sCLpTpZt3D6B8UMsizEZhe5lJ0,4321
|
17
|
-
fameio/source/results/conversion.py,sha256=j75BP5jdSFMY251SMk5SMOVURVi_uUKapCSkMak_0Ro,3793
|
18
|
-
fameio/source/results/csv_writer.py,sha256=OHjglOdEzQcWrupVMlt7ya5jC3prPP2FaX6D_yLP_xY,4216
|
19
|
-
fameio/source/results/data_transformer.py,sha256=Elbb5tHzvGeGGXgw7O-mvM5IzGlddY858d3lEImBZGA,6222
|
20
|
-
fameio/source/results/output_dao.py,sha256=8FocGe4yyH3EdHD5Chw9uCGnDetfJoSglBga0o3lnWE,3960
|
21
|
-
fameio/source/results/reader.py,sha256=hluy_hPCbq-bbu6qyRUuph710ANXPfEv9B5Y0YyzBO0,4791
|
22
|
-
fameio/source/scenario/__init__.py,sha256=YfJvz275GWX8kVWMSMRcF3KsUQNqSAPrwBgNV7tqBTY,372
|
23
|
-
fameio/source/scenario/agent.py,sha256=YbzEP-mahBPkKCbyAKm9u-JTmoIrmo36ql9VhWcOtTw,3830
|
24
|
-
fameio/source/scenario/attribute.py,sha256=iRGVkH33wKgB-B2GcmaDo2P4Mcj_qzzGryE_0YPhC3M,5002
|
25
|
-
fameio/source/scenario/contract.py,sha256=4ewwtX9bXgM5dczKbiXvafQKloxkeG_A21_ZrcTC5cI,8853
|
26
|
-
fameio/source/scenario/exception.py,sha256=0dkBAs2pcV5zeqEUF8eYVZ51b-2pewWyLDjggjANQyo,1455
|
27
|
-
fameio/source/scenario/fameiofactory.py,sha256=7P-x8i9sSU9sIkOlgF6gVRFuNacFMUBrBh4KdHoAUtU,1376
|
28
|
-
fameio/source/scenario/generalproperties.py,sha256=SIRmIyDFMhdzNtHfGnK4jdsZZtS8fxtKizqL6XzANyA,4593
|
29
|
-
fameio/source/scenario/scenario.py,sha256=z5SaEXhfJcEDtQv_WtAo8YJVYexypz0JQdcN5d1LLOo,3582
|
30
|
-
fameio/source/schema/__init__.py,sha256=ZGTyliDbjlYGPAjB9bbggzACOYWdhm4I1VSmm7YGmTk,270
|
31
|
-
fameio/source/schema/agenttype.py,sha256=vXzcSGz-swftDESy5GL_6p4FXBU5kYg1bkzVnISQiXA,3331
|
32
|
-
fameio/source/schema/attribute.py,sha256=pgxUjacqRhIJRgIrkBz3_r1LbbsRe9KssajRMyVRYFo,8214
|
33
|
-
fameio/source/schema/exception.py,sha256=NMftGnrFOaS3MwrjZl8qbx3bi6KYUxhzHJIX1v--B5M,224
|
34
|
-
fameio/source/schema/schema.py,sha256=mJyPlIhw_5AJZwNnsPCKhtfbjXKsTozBgFz5Xrkowic,1715
|
35
|
-
fameio-1.8.1.dist-info/LICENSE.txt,sha256=eGHBZnhr9CWjE95SWjRfmhtK1lvVn5X4Fpf3KrrAZDg,10391
|
36
|
-
fameio-1.8.1.dist-info/METADATA,sha256=np8UZsZi3Y4c6tUox6iyqN7xzkorZrd9qxhbnOF-kkE,29656
|
37
|
-
fameio-1.8.1.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
38
|
-
fameio-1.8.1.dist-info/entry_points.txt,sha256=9pwKjYQ6B5n1umD1wjrGU3t9jUJ0fawThOt0wTKoqUA,126
|
39
|
-
fameio-1.8.1.dist-info/top_level.txt,sha256=awP3PJ9u2oNrXHwVGcSaXYYnpCa1-4OXrUuYhnWjlMA,7
|
40
|
-
fameio-1.8.1.dist-info/RECORD,,
|
@@ -1 +0,0 @@
|
|
1
|
-
fameio
|
File without changes
|