shepherd-core 2025.6.2__py3-none-any.whl → 2025.6.4__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.
- shepherd_core/data_models/base/cal_measurement.py +4 -5
- shepherd_core/data_models/base/calibration.py +8 -10
- shepherd_core/data_models/base/content.py +2 -3
- shepherd_core/data_models/base/shepherd.py +31 -15
- shepherd_core/data_models/base/wrapper.py +3 -4
- shepherd_core/data_models/content/energy_environment.py +4 -5
- shepherd_core/data_models/content/firmware.py +3 -5
- shepherd_core/data_models/content/virtual_harvester.py +5 -6
- shepherd_core/data_models/experiment/experiment.py +9 -17
- shepherd_core/data_models/experiment/observer_features.py +15 -37
- shepherd_core/data_models/experiment/target_config.py +10 -11
- shepherd_core/data_models/task/__init__.py +3 -4
- shepherd_core/data_models/task/emulation.py +10 -14
- shepherd_core/data_models/task/firmware_mod.py +2 -4
- shepherd_core/data_models/task/harvest.py +4 -7
- shepherd_core/data_models/task/observer_tasks.py +7 -8
- shepherd_core/data_models/task/programming.py +1 -2
- shepherd_core/data_models/task/testbed_tasks.py +2 -9
- shepherd_core/data_models/testbed/cape.py +3 -5
- shepherd_core/data_models/testbed/gpio.py +7 -8
- shepherd_core/data_models/testbed/mcu.py +1 -2
- shepherd_core/data_models/testbed/observer.py +5 -6
- shepherd_core/data_models/testbed/target.py +4 -6
- shepherd_core/data_models/testbed/testbed.py +2 -3
- shepherd_core/decoder_waveform/uart.py +11 -13
- shepherd_core/fw_tools/converter.py +1 -2
- shepherd_core/fw_tools/converter_elf.py +1 -2
- shepherd_core/fw_tools/patcher.py +5 -6
- shepherd_core/inventory/python.py +8 -9
- shepherd_core/inventory/system.py +1 -2
- shepherd_core/inventory/target.py +1 -2
- shepherd_core/logger.py +1 -2
- shepherd_core/reader.py +18 -23
- shepherd_core/testbed_client/client_abc_fix.py +2 -7
- shepherd_core/testbed_client/client_web.py +5 -9
- shepherd_core/testbed_client/fixtures.py +3 -5
- shepherd_core/testbed_client/user_model.py +4 -5
- shepherd_core/version.py +1 -1
- shepherd_core/vsource/virtual_converter_model.py +1 -2
- shepherd_core/vsource/virtual_harvester_simulation.py +1 -2
- shepherd_core/vsource/virtual_source_model.py +3 -5
- shepherd_core/vsource/virtual_source_simulation.py +1 -2
- shepherd_core/writer.py +12 -14
- {shepherd_core-2025.6.2.dist-info → shepherd_core-2025.6.4.dist-info}/METADATA +2 -3
- shepherd_core-2025.6.4.dist-info/RECORD +83 -0
- shepherd_core-2025.6.2.dist-info/RECORD +0 -83
- {shepherd_core-2025.6.2.dist-info → shepherd_core-2025.6.4.dist-info}/WHEEL +0 -0
- {shepherd_core-2025.6.2.dist-info → shepherd_core-2025.6.4.dist-info}/top_level.txt +0 -0
- {shepherd_core-2025.6.2.dist-info → shepherd_core-2025.6.4.dist-info}/zip-safe +0 -0
|
@@ -4,9 +4,7 @@ from collections.abc import Set as AbstractSet
|
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
from pathlib import PurePosixPath
|
|
6
6
|
from typing import Annotated
|
|
7
|
-
from typing import Optional
|
|
8
7
|
from typing import TypedDict
|
|
9
|
-
from typing import Union
|
|
10
8
|
|
|
11
9
|
from pydantic import Field
|
|
12
10
|
from pydantic import model_validator
|
|
@@ -31,9 +29,9 @@ from .helper_paths import path_posix
|
|
|
31
29
|
class FirmwareModTask(ShpModel):
|
|
32
30
|
"""Config for Task that adds the custom ID to the firmware & stores it into a file."""
|
|
33
31
|
|
|
34
|
-
data:
|
|
32
|
+
data: FirmwareStr | Path
|
|
35
33
|
data_type: FirmwareDType
|
|
36
|
-
custom_id:
|
|
34
|
+
custom_id: IdInt16 | None = None
|
|
37
35
|
firmware_file: Path
|
|
38
36
|
|
|
39
37
|
verbose: Annotated[int, Field(ge=0, le=4)] = 2
|
|
@@ -6,12 +6,10 @@ from datetime import timedelta
|
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
from pathlib import PurePosixPath
|
|
8
8
|
from typing import Annotated
|
|
9
|
-
from typing import Optional
|
|
10
9
|
|
|
11
10
|
from pydantic import Field
|
|
12
11
|
from pydantic import model_validator
|
|
13
12
|
from typing_extensions import Self
|
|
14
|
-
from typing_extensions import deprecated
|
|
15
13
|
|
|
16
14
|
from shepherd_core.data_models.base.shepherd import ShpModel
|
|
17
15
|
from shepherd_core.data_models.base.timezone import local_tz
|
|
@@ -35,14 +33,13 @@ class HarvestTask(ShpModel):
|
|
|
35
33
|
"""
|
|
36
34
|
force_overwrite: bool = False
|
|
37
35
|
""" ⤷ Overwrite existing file"""
|
|
38
|
-
output_compression:
|
|
36
|
+
output_compression: Compression | None = Compression.default
|
|
39
37
|
""" ⤷ should be 1 (level 1 gzip), lzf, or None (order of recommendation)"""
|
|
40
38
|
|
|
41
|
-
time_start:
|
|
39
|
+
time_start: datetime | None = None
|
|
42
40
|
""" timestamp or unix epoch time, None = ASAP"""
|
|
43
|
-
duration:
|
|
41
|
+
duration: timedelta | None = None
|
|
44
42
|
""" ⤷ Duration of recording in seconds, None = till EOFSys"""
|
|
45
|
-
abort_on_error: Annotated[bool, deprecated("has no effect")] = False
|
|
46
43
|
|
|
47
44
|
# emulation-specific
|
|
48
45
|
use_cal_default: bool = False
|
|
@@ -52,7 +49,7 @@ class HarvestTask(ShpModel):
|
|
|
52
49
|
""" ⤷ Choose one of the predefined virtual harvesters or configure a new one
|
|
53
50
|
"""
|
|
54
51
|
power_tracing: PowerTracing = PowerTracing()
|
|
55
|
-
sys_logging:
|
|
52
|
+
sys_logging: SystemLogging | None = SystemLogging()
|
|
56
53
|
|
|
57
54
|
verbose: Annotated[int, Field(ge=0, le=4)] = 2
|
|
58
55
|
""" ⤷ 0=Errors, 1=Warnings, 2=Info, 3=Debug"""
|
|
@@ -5,7 +5,6 @@ from datetime import datetime
|
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
from pathlib import PurePosixPath
|
|
7
7
|
from typing import Annotated
|
|
8
|
-
from typing import Optional
|
|
9
8
|
|
|
10
9
|
from pydantic import validate_call
|
|
11
10
|
from typing_extensions import Self
|
|
@@ -29,20 +28,20 @@ class ObserverTasks(ShpModel):
|
|
|
29
28
|
observer: NameStr
|
|
30
29
|
|
|
31
30
|
# PRE PROCESS
|
|
32
|
-
time_prep:
|
|
31
|
+
time_prep: datetime | None = None # TODO: currently not used
|
|
33
32
|
root_path: Path
|
|
34
33
|
|
|
35
34
|
# fw mod, store as hex-file and program
|
|
36
|
-
fw1_mod:
|
|
37
|
-
fw2_mod:
|
|
38
|
-
fw1_prog:
|
|
39
|
-
fw2_prog:
|
|
35
|
+
fw1_mod: FirmwareModTask | None = None
|
|
36
|
+
fw2_mod: FirmwareModTask | None = None
|
|
37
|
+
fw1_prog: ProgrammingTask | None = None
|
|
38
|
+
fw2_prog: ProgrammingTask | None = None
|
|
40
39
|
|
|
41
40
|
# MAIN PROCESS
|
|
42
|
-
emulation:
|
|
41
|
+
emulation: EmulationTask | None = None
|
|
43
42
|
|
|
44
43
|
# deprecations, TODO: remove before public release
|
|
45
|
-
owner_id: Annotated[
|
|
44
|
+
owner_id: Annotated[IdInt | None, deprecated("not needed anymore")] = None
|
|
46
45
|
abort_on_error: Annotated[bool, deprecated("has no effect")] = False
|
|
47
46
|
|
|
48
47
|
# post_copy / cleanup, Todo: could also just intake emuTask
|
|
@@ -4,7 +4,6 @@ from collections.abc import Set as AbstractSet
|
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
from pathlib import PurePosixPath
|
|
6
6
|
from typing import Annotated
|
|
7
|
-
from typing import Optional
|
|
8
7
|
|
|
9
8
|
from pydantic import Field
|
|
10
9
|
from pydantic import model_validator
|
|
@@ -60,7 +59,7 @@ class ProgrammingTask(ShpModel):
|
|
|
60
59
|
tgt_id: IdInt,
|
|
61
60
|
mcu_port: MCUPort,
|
|
62
61
|
fw_path: Path,
|
|
63
|
-
) ->
|
|
62
|
+
) -> Self | None:
|
|
64
63
|
obs = tb.get_observer(tgt_id)
|
|
65
64
|
tgt_cfg = xp.get_target_config(tgt_id)
|
|
66
65
|
|
|
@@ -4,14 +4,11 @@ from pathlib import Path
|
|
|
4
4
|
from pathlib import PurePosixPath
|
|
5
5
|
from typing import TYPE_CHECKING
|
|
6
6
|
from typing import Annotated
|
|
7
|
-
from typing import Optional
|
|
8
7
|
|
|
9
8
|
from pydantic import Field
|
|
10
9
|
from pydantic import validate_call
|
|
11
10
|
from typing_extensions import Self
|
|
12
|
-
from typing_extensions import deprecated
|
|
13
11
|
|
|
14
|
-
from shepherd_core.data_models.base.content import IdInt
|
|
15
12
|
from shepherd_core.data_models.base.content import NameStr
|
|
16
13
|
from shepherd_core.data_models.base.shepherd import ShpModel
|
|
17
14
|
from shepherd_core.data_models.experiment.experiment import Experiment
|
|
@@ -29,13 +26,9 @@ class TestbedTasks(ShpModel):
|
|
|
29
26
|
name: NameStr
|
|
30
27
|
observer_tasks: Annotated[list[ObserverTasks], Field(min_length=1, max_length=128)]
|
|
31
28
|
|
|
32
|
-
# deprecated, TODO: remove before public release
|
|
33
|
-
email_results: Annotated[Optional[bool], deprecated("not needed anymore")] = False
|
|
34
|
-
owner_id: Annotated[Optional[IdInt], deprecated("not needed anymore")] = None
|
|
35
|
-
|
|
36
29
|
@classmethod
|
|
37
30
|
@validate_call
|
|
38
|
-
def from_xp(cls, xp: Experiment, tb:
|
|
31
|
+
def from_xp(cls, xp: Experiment, tb: Testbed | None = None) -> Self:
|
|
39
32
|
if tb is None:
|
|
40
33
|
# TODO: is tb-argument really needed? prob. not
|
|
41
34
|
tb = Testbed() # this will query the first (and only) entry of client
|
|
@@ -47,7 +40,7 @@ class TestbedTasks(ShpModel):
|
|
|
47
40
|
observer_tasks=obs_tasks,
|
|
48
41
|
)
|
|
49
42
|
|
|
50
|
-
def get_observer_tasks(self, observer: str) ->
|
|
43
|
+
def get_observer_tasks(self, observer: str) -> ObserverTasks | None:
|
|
51
44
|
for tasks in self.observer_tasks:
|
|
52
45
|
if observer == tasks.observer:
|
|
53
46
|
return tasks
|
|
@@ -4,8 +4,6 @@ from datetime import date
|
|
|
4
4
|
from datetime import datetime
|
|
5
5
|
from enum import Enum
|
|
6
6
|
from typing import Any
|
|
7
|
-
from typing import Optional
|
|
8
|
-
from typing import Union
|
|
9
7
|
|
|
10
8
|
from pydantic import Field
|
|
11
9
|
from pydantic import model_validator
|
|
@@ -31,12 +29,12 @@ class Cape(ShpModel, title="Shepherd-Cape"):
|
|
|
31
29
|
name: NameStr
|
|
32
30
|
version: NameStr
|
|
33
31
|
description: SafeStr
|
|
34
|
-
comment:
|
|
32
|
+
comment: SafeStr | None = None
|
|
35
33
|
# TODO: wake_interval, calibration
|
|
36
34
|
|
|
37
35
|
active: bool = True
|
|
38
|
-
created:
|
|
39
|
-
calibrated:
|
|
36
|
+
created: date | datetime = Field(default_factory=datetime.now)
|
|
37
|
+
calibrated: date | datetime | None = None
|
|
40
38
|
|
|
41
39
|
def __str__(self) -> str:
|
|
42
40
|
return self.name
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
from enum import Enum
|
|
4
4
|
from typing import Annotated
|
|
5
5
|
from typing import Any
|
|
6
|
-
from typing import Optional
|
|
7
6
|
|
|
8
7
|
from pydantic import Field
|
|
9
8
|
from pydantic import StringConstraints
|
|
@@ -30,16 +29,16 @@ class GPIO(ShpModel, title="GPIO of Observer Node"):
|
|
|
30
29
|
|
|
31
30
|
id: IdInt
|
|
32
31
|
name: NameStr
|
|
33
|
-
description:
|
|
34
|
-
comment:
|
|
32
|
+
description: SafeStr | None = None
|
|
33
|
+
comment: SafeStr | None = None
|
|
35
34
|
|
|
36
35
|
direction: Direction = Direction.Input
|
|
37
|
-
dir_switch:
|
|
36
|
+
dir_switch: Annotated[str, StringConstraints(max_length=32)] | None = None
|
|
38
37
|
|
|
39
|
-
reg_pru:
|
|
40
|
-
pin_pru:
|
|
41
|
-
reg_sys:
|
|
42
|
-
pin_sys:
|
|
38
|
+
reg_pru: Annotated[str, StringConstraints(max_length=10)] | None = None
|
|
39
|
+
pin_pru: Annotated[str, StringConstraints(max_length=10)] | None = None
|
|
40
|
+
reg_sys: Annotated[int, Field(ge=0)] | None = None
|
|
41
|
+
pin_sys: Annotated[str, StringConstraints(max_length=10)] | None = None
|
|
43
42
|
|
|
44
43
|
def __str__(self) -> str:
|
|
45
44
|
return self.name
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
from enum import Enum
|
|
4
4
|
from typing import Annotated
|
|
5
5
|
from typing import Any
|
|
6
|
-
from typing import Optional
|
|
7
6
|
|
|
8
7
|
from pydantic import Field
|
|
9
8
|
from pydantic import model_validator
|
|
@@ -30,7 +29,7 @@ class MCU(ShpModel, title="Microcontroller of the Target Node"):
|
|
|
30
29
|
id: IdInt
|
|
31
30
|
name: NameStr
|
|
32
31
|
description: SafeStr
|
|
33
|
-
comment:
|
|
32
|
+
comment: SafeStr | None = None
|
|
34
33
|
|
|
35
34
|
platform: NameStr
|
|
36
35
|
core: NameStr
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
from datetime import datetime
|
|
4
4
|
from typing import Annotated
|
|
5
5
|
from typing import Any
|
|
6
|
-
from typing import Optional
|
|
7
6
|
|
|
8
7
|
from pydantic import Field
|
|
9
8
|
from pydantic import IPvAnyAddress
|
|
@@ -33,7 +32,7 @@ class Observer(ShpModel, title="Shepherd-Sheep"):
|
|
|
33
32
|
id: IdInt
|
|
34
33
|
name: NameStr
|
|
35
34
|
description: SafeStr
|
|
36
|
-
comment:
|
|
35
|
+
comment: SafeStr | None = None
|
|
37
36
|
|
|
38
37
|
ip: IPvAnyAddress
|
|
39
38
|
mac: MACStr
|
|
@@ -46,12 +45,12 @@ class Observer(ShpModel, title="Shepherd-Sheep"):
|
|
|
46
45
|
""" ⤷ cfaed-floor"""
|
|
47
46
|
|
|
48
47
|
active: bool = True
|
|
49
|
-
cape:
|
|
50
|
-
target_a:
|
|
51
|
-
target_b:
|
|
48
|
+
cape: Cape | None = None
|
|
49
|
+
target_a: Target | None = None
|
|
50
|
+
target_b: Target | None = None
|
|
52
51
|
|
|
53
52
|
created: datetime = Field(default_factory=datetime.now)
|
|
54
|
-
alive_last:
|
|
53
|
+
alive_last: datetime | None = None
|
|
55
54
|
|
|
56
55
|
def __str__(self) -> str:
|
|
57
56
|
return self.name
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
from datetime import datetime
|
|
4
4
|
from typing import Annotated
|
|
5
5
|
from typing import Any
|
|
6
|
-
from typing import Optional
|
|
7
|
-
from typing import Union
|
|
8
6
|
|
|
9
7
|
from pydantic import Field
|
|
10
8
|
from pydantic import model_validator
|
|
@@ -30,15 +28,15 @@ class Target(ShpModel, title="Target Node (DuT)"):
|
|
|
30
28
|
version: NameStr
|
|
31
29
|
description: SafeStr
|
|
32
30
|
|
|
33
|
-
comment:
|
|
31
|
+
comment: SafeStr | None = None
|
|
34
32
|
|
|
35
33
|
active: bool = True
|
|
36
34
|
created: datetime = Field(default_factory=datetime.now)
|
|
37
35
|
|
|
38
|
-
testbed_id:
|
|
36
|
+
testbed_id: IdInt16 | None = None
|
|
39
37
|
""" ⤷ is derived from ID (targets are still selected by id!)"""
|
|
40
|
-
mcu1:
|
|
41
|
-
mcu2:
|
|
38
|
+
mcu1: MCU | NameStr
|
|
39
|
+
mcu2: MCU | NameStr | None = None
|
|
42
40
|
|
|
43
41
|
# TODO: programming pins per mcu should be here (or better in Cape)
|
|
44
42
|
|
|
@@ -4,7 +4,6 @@ from datetime import timedelta
|
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
from typing import Annotated
|
|
6
6
|
from typing import Any
|
|
7
|
-
from typing import Optional
|
|
8
7
|
|
|
9
8
|
from pydantic import Field
|
|
10
9
|
from pydantic import HttpUrl
|
|
@@ -29,9 +28,9 @@ class Testbed(ShpModel):
|
|
|
29
28
|
id: IdInt
|
|
30
29
|
name: NameStr
|
|
31
30
|
description: SafeStr
|
|
32
|
-
comment:
|
|
31
|
+
comment: SafeStr | None = None
|
|
33
32
|
|
|
34
|
-
url:
|
|
33
|
+
url: HttpUrl | None = None
|
|
35
34
|
|
|
36
35
|
observers: Annotated[list[Observer], Field(min_length=1, max_length=128)]
|
|
37
36
|
|
|
@@ -23,8 +23,6 @@ https://sigrok.org/wiki/Protocol_decoder:Uart
|
|
|
23
23
|
|
|
24
24
|
from enum import Enum
|
|
25
25
|
from pathlib import Path
|
|
26
|
-
from typing import Optional
|
|
27
|
-
from typing import Union
|
|
28
26
|
|
|
29
27
|
import numpy as np
|
|
30
28
|
|
|
@@ -51,12 +49,12 @@ class Uart:
|
|
|
51
49
|
|
|
52
50
|
def __init__(
|
|
53
51
|
self,
|
|
54
|
-
content:
|
|
55
|
-
baud_rate:
|
|
56
|
-
frame_length:
|
|
57
|
-
inversion:
|
|
58
|
-
parity:
|
|
59
|
-
bit_order:
|
|
52
|
+
content: Path | np.ndarray,
|
|
53
|
+
baud_rate: int | None = None,
|
|
54
|
+
frame_length: int | None = 8,
|
|
55
|
+
inversion: bool | None = None,
|
|
56
|
+
parity: Parity | None = Parity.no,
|
|
57
|
+
bit_order: BitOrder | None = BitOrder.lsb_first,
|
|
60
58
|
) -> None:
|
|
61
59
|
"""Provide a file with two columns: TS & Signal.
|
|
62
60
|
|
|
@@ -115,9 +113,9 @@ class Uart:
|
|
|
115
113
|
log.error("Signal still inverted?!? Check parameters and input")
|
|
116
114
|
|
|
117
115
|
# results
|
|
118
|
-
self.events_symbols:
|
|
119
|
-
self.events_lines:
|
|
120
|
-
self.text:
|
|
116
|
+
self.events_symbols: np.ndarray | None = None
|
|
117
|
+
self.events_lines: np.ndarray | None = None
|
|
118
|
+
self.text: str | None = None
|
|
121
119
|
|
|
122
120
|
def _convert_analog2digital(self, *, invert: bool = False) -> None:
|
|
123
121
|
"""Divide dimension in two, divided by mean-value."""
|
|
@@ -208,9 +206,9 @@ class Uart:
|
|
|
208
206
|
if self.events_symbols is not None:
|
|
209
207
|
return self.events_symbols
|
|
210
208
|
|
|
211
|
-
pos_df:
|
|
209
|
+
pos_df: int | None = None
|
|
212
210
|
symbol: int = 0
|
|
213
|
-
t_start:
|
|
211
|
+
t_start: float | None = None
|
|
214
212
|
content: list = []
|
|
215
213
|
|
|
216
214
|
for time, value, steps in self.events_sig:
|
|
@@ -4,7 +4,6 @@ import base64
|
|
|
4
4
|
import hashlib
|
|
5
5
|
import shutil
|
|
6
6
|
from pathlib import Path
|
|
7
|
-
from typing import Union
|
|
8
7
|
|
|
9
8
|
import zstandard as zstd
|
|
10
9
|
from pydantic import validate_call
|
|
@@ -81,7 +80,7 @@ def base64_to_hash(content: str) -> str:
|
|
|
81
80
|
|
|
82
81
|
|
|
83
82
|
@validate_call
|
|
84
|
-
def extract_firmware(data:
|
|
83
|
+
def extract_firmware(data: str | Path, data_type: FirmwareDType, file_path: Path) -> Path:
|
|
85
84
|
"""Make embedded firmware-data usable in filesystem.
|
|
86
85
|
|
|
87
86
|
- base64-string will be transformed to file
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import subprocess
|
|
4
4
|
from pathlib import Path
|
|
5
|
-
from typing import Optional
|
|
6
5
|
|
|
7
6
|
from pydantic import validate_call
|
|
8
7
|
|
|
@@ -10,7 +9,7 @@ from pydantic import validate_call
|
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
@validate_call
|
|
13
|
-
def elf_to_hex(file_elf: Path, file_hex:
|
|
12
|
+
def elf_to_hex(file_elf: Path, file_hex: Path | None = None) -> Path:
|
|
14
13
|
"""Convert ELF to hex file using objcopy."""
|
|
15
14
|
if not file_elf.is_file():
|
|
16
15
|
raise ValueError("Fn needs an existing file as input")
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
from typing import Annotated
|
|
5
|
-
from typing import Optional
|
|
6
5
|
|
|
7
6
|
from pydantic import Field
|
|
8
7
|
from pydantic import validate_call
|
|
@@ -49,7 +48,7 @@ def find_symbol(file_elf: Path, symbol: str) -> bool:
|
|
|
49
48
|
|
|
50
49
|
|
|
51
50
|
@validate_call
|
|
52
|
-
def read_symbol(file_elf: Path, symbol: str, length: int) ->
|
|
51
|
+
def read_symbol(file_elf: Path, symbol: str, length: int) -> int | None:
|
|
53
52
|
"""Read value of symbol in ELF-File.
|
|
54
53
|
|
|
55
54
|
Will be interpreted as int.
|
|
@@ -65,12 +64,12 @@ def read_symbol(file_elf: Path, symbol: str, length: int) -> Optional[int]:
|
|
|
65
64
|
return int.from_bytes(bytes=value_raw, byteorder=elf.endian, signed=False)
|
|
66
65
|
|
|
67
66
|
|
|
68
|
-
def read_uid(file_elf: Path) ->
|
|
67
|
+
def read_uid(file_elf: Path) -> int | None:
|
|
69
68
|
"""Read value of UID-symbol for shepherd testbed."""
|
|
70
69
|
return read_symbol(file_elf, symbol=config.UID_NAME, length=config.UID_SIZE)
|
|
71
70
|
|
|
72
71
|
|
|
73
|
-
def read_arch(file_elf: Path) ->
|
|
72
|
+
def read_arch(file_elf: Path) -> str | None:
|
|
74
73
|
"""Determine chip-architecture from elf-metadata."""
|
|
75
74
|
if not is_elf(file_elf):
|
|
76
75
|
return None
|
|
@@ -90,7 +89,7 @@ def modify_symbol_value(
|
|
|
90
89
|
value: Annotated[int, Field(ge=0, lt=2 ** (8 * config.UID_SIZE))],
|
|
91
90
|
*,
|
|
92
91
|
overwrite: bool = False,
|
|
93
|
-
) ->
|
|
92
|
+
) -> Path | None:
|
|
94
93
|
"""Replace value of uint16-symbol in ELF-File.
|
|
95
94
|
|
|
96
95
|
Hardcoded for uint16_t (2 byte).
|
|
@@ -129,6 +128,6 @@ def modify_symbol_value(
|
|
|
129
128
|
return file_new
|
|
130
129
|
|
|
131
130
|
|
|
132
|
-
def modify_uid(file_elf: Path, value: int) ->
|
|
131
|
+
def modify_uid(file_elf: Path, value: int) -> Path | None:
|
|
133
132
|
"""Replace value of UID-symbol for shepherd testbed."""
|
|
134
133
|
return modify_symbol_value(file_elf, symbol=config.UID_NAME, value=value, overwrite=True)
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import platform
|
|
4
4
|
from contextlib import suppress
|
|
5
5
|
from importlib import import_module
|
|
6
|
-
from typing import Optional
|
|
7
6
|
|
|
8
7
|
from pydantic import ConfigDict
|
|
9
8
|
from typing_extensions import Self
|
|
@@ -15,14 +14,14 @@ class PythonInventory(ShpModel):
|
|
|
15
14
|
"""Python related inventory model."""
|
|
16
15
|
|
|
17
16
|
# program versions
|
|
18
|
-
h5py:
|
|
19
|
-
numpy:
|
|
20
|
-
pydantic:
|
|
21
|
-
python:
|
|
22
|
-
shepherd_core:
|
|
23
|
-
shepherd_sheep:
|
|
24
|
-
yaml:
|
|
25
|
-
zstandard:
|
|
17
|
+
h5py: str | None = None
|
|
18
|
+
numpy: str | None = None
|
|
19
|
+
pydantic: str | None = None
|
|
20
|
+
python: str | None = None
|
|
21
|
+
shepherd_core: str | None = None
|
|
22
|
+
shepherd_sheep: str | None = None
|
|
23
|
+
yaml: str | None = None
|
|
24
|
+
zstandard: str | None = None
|
|
26
25
|
|
|
27
26
|
model_config = ConfigDict(str_min_length=0)
|
|
28
27
|
|
|
@@ -9,7 +9,6 @@ from datetime import datetime
|
|
|
9
9
|
from pathlib import Path
|
|
10
10
|
from types import MappingProxyType
|
|
11
11
|
from typing import Any
|
|
12
|
-
from typing import Optional
|
|
13
12
|
|
|
14
13
|
from typing_extensions import Self
|
|
15
14
|
|
|
@@ -41,7 +40,7 @@ class SystemInventory(ShpModel):
|
|
|
41
40
|
machine: str
|
|
42
41
|
processor: str
|
|
43
42
|
|
|
44
|
-
ptp:
|
|
43
|
+
ptp: str | None = None
|
|
45
44
|
|
|
46
45
|
hostname: str
|
|
47
46
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"""Hardware related inventory model."""
|
|
2
2
|
|
|
3
3
|
from collections.abc import Sequence
|
|
4
|
-
from typing import Optional
|
|
5
4
|
|
|
6
5
|
from pydantic import ConfigDict
|
|
7
6
|
from typing_extensions import Self
|
|
@@ -12,7 +11,7 @@ from shepherd_core.data_models import ShpModel
|
|
|
12
11
|
class TargetInventory(ShpModel):
|
|
13
12
|
"""Hardware related inventory model."""
|
|
14
13
|
|
|
15
|
-
cape:
|
|
14
|
+
cape: str | None = None
|
|
16
15
|
targets: Sequence[str] = ()
|
|
17
16
|
|
|
18
17
|
model_config = ConfigDict(str_min_length=0)
|
shepherd_core/logger.py
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
4
|
import logging.handlers
|
|
5
|
-
from typing import Union
|
|
6
5
|
|
|
7
6
|
import chromalog
|
|
8
7
|
|
|
@@ -18,7 +17,7 @@ def get_verbose_level() -> int:
|
|
|
18
17
|
return verbose_level
|
|
19
18
|
|
|
20
19
|
|
|
21
|
-
def set_log_verbose_level(log_:
|
|
20
|
+
def set_log_verbose_level(log_: logging.Logger | logging.Handler, verbose: int) -> None:
|
|
22
21
|
"""Set log level of shepherd."""
|
|
23
22
|
if verbose == 0:
|
|
24
23
|
log_.setLevel(logging.ERROR)
|