shepherd-core 2023.12.1__tar.gz → 2024.4.1__tar.gz

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 (126) hide show
  1. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/PKG-INFO +48 -33
  2. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/README.md +41 -24
  3. shepherd_core-2024.4.1/pyproject.toml +112 -0
  4. shepherd_core-2024.4.1/setup.cfg +4 -0
  5. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/__init__.py +3 -2
  6. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/base/calibration.py +3 -1
  7. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/base/content.py +11 -4
  8. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/base/shepherd.py +2 -0
  9. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/content/energy_environment.py +1 -1
  10. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/content/virtual_harvester.py +1 -1
  11. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/content/virtual_source.py +18 -13
  12. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/experiment/experiment.py +10 -10
  13. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/experiment/observer_features.py +5 -6
  14. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/task/observer_tasks.py +1 -1
  15. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/task/testbed_tasks.py +7 -3
  16. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/testbed/cape.py +1 -1
  17. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/testbed/gpio.py +1 -1
  18. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/testbed/mcu.py +1 -1
  19. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/testbed/observer.py +1 -1
  20. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/testbed/target.py +1 -1
  21. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/testbed/testbed.py +1 -1
  22. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/decoder_waveform/uart.py +1 -0
  23. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/fw_tools/validation.py +1 -2
  24. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/inventory/__init__.py +51 -1
  25. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/inventory/system.py +8 -0
  26. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/reader.py +19 -16
  27. shepherd_core-2024.4.1/shepherd_core/testbed_client/cache_path.py +15 -0
  28. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/testbed_client/client.py +2 -3
  29. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/testbed_client/fixtures.py +4 -1
  30. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/testbed_client/user_model.py +6 -4
  31. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/vsource/virtual_converter_model.py +1 -1
  32. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/vsource/virtual_harvester_model.py +1 -0
  33. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/vsource/virtual_source_model.py +1 -0
  34. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/writer.py +5 -2
  35. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core.egg-info/PKG-INFO +49 -34
  36. shepherd_core-2024.4.1/shepherd_core.egg-info/SOURCES.txt +72 -0
  37. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core.egg-info/top_level.txt +0 -1
  38. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/tests/test_examples.py +6 -5
  39. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/tests/test_writer.py +2 -2
  40. shepherd_core-2023.12.1/pyproject.toml +0 -10
  41. shepherd_core-2023.12.1/setup.cfg +0 -86
  42. shepherd_core-2023.12.1/shepherd_core/data_models/content/_external_fixtures.yaml +0 -394
  43. shepherd_core-2023.12.1/shepherd_core/data_models/content/energy_environment_fixture.yaml +0 -50
  44. shepherd_core-2023.12.1/shepherd_core/data_models/content/virtual_harvester_fixture.yaml +0 -159
  45. shepherd_core-2023.12.1/shepherd_core/data_models/content/virtual_source_fixture.yaml +0 -229
  46. shepherd_core-2023.12.1/shepherd_core/data_models/testbed/cape_fixture.yaml +0 -94
  47. shepherd_core-2023.12.1/shepherd_core/data_models/testbed/gpio_fixture.yaml +0 -166
  48. shepherd_core-2023.12.1/shepherd_core/data_models/testbed/mcu_fixture.yaml +0 -19
  49. shepherd_core-2023.12.1/shepherd_core/data_models/testbed/observer_fixture.yaml +0 -220
  50. shepherd_core-2023.12.1/shepherd_core/data_models/testbed/target_fixture.yaml +0 -137
  51. shepherd_core-2023.12.1/shepherd_core/data_models/testbed/testbed_fixture.yaml +0 -25
  52. shepherd_core-2023.12.1/shepherd_core.egg-info/SOURCES.txt +0 -126
  53. shepherd_core-2023.12.1/tests/__init__.py +0 -0
  54. shepherd_core-2023.12.1/tests/conftest.py +0 -64
  55. shepherd_core-2023.12.1/tests/data_models/__init__.py +0 -0
  56. shepherd_core-2023.12.1/tests/data_models/conftest.py +0 -14
  57. shepherd_core-2023.12.1/tests/data_models/example_cal_data.yaml +0 -31
  58. shepherd_core-2023.12.1/tests/data_models/example_cal_data_faulty.yaml +0 -29
  59. shepherd_core-2023.12.1/tests/data_models/example_cal_meas.yaml +0 -178
  60. shepherd_core-2023.12.1/tests/data_models/example_cal_meas_faulty1.yaml +0 -142
  61. shepherd_core-2023.12.1/tests/data_models/example_cal_meas_faulty2.yaml +0 -136
  62. shepherd_core-2023.12.1/tests/data_models/example_config_emulator.yaml +0 -41
  63. shepherd_core-2023.12.1/tests/data_models/example_config_experiment.yaml +0 -16
  64. shepherd_core-2023.12.1/tests/data_models/example_config_experiment_alternative.yaml +0 -14
  65. shepherd_core-2023.12.1/tests/data_models/example_config_harvester.yaml +0 -15
  66. shepherd_core-2023.12.1/tests/data_models/example_config_testbed.yaml +0 -26
  67. shepherd_core-2023.12.1/tests/data_models/example_config_virtsource.yaml +0 -78
  68. shepherd_core-2023.12.1/tests/data_models/test_base_models.py +0 -205
  69. shepherd_core-2023.12.1/tests/data_models/test_content_fixtures.py +0 -41
  70. shepherd_core-2023.12.1/tests/data_models/test_content_models.py +0 -282
  71. shepherd_core-2023.12.1/tests/data_models/test_examples.py +0 -48
  72. shepherd_core-2023.12.1/tests/data_models/test_experiment_models.py +0 -277
  73. shepherd_core-2023.12.1/tests/data_models/test_task_generation.py +0 -52
  74. shepherd_core-2023.12.1/tests/data_models/test_task_models.py +0 -131
  75. shepherd_core-2023.12.1/tests/data_models/test_testbed_fixtures.py +0 -47
  76. shepherd_core-2023.12.1/tests/data_models/test_testbed_models.py +0 -187
  77. shepherd_core-2023.12.1/tests/decoder_waveform/__init__.py +0 -0
  78. shepherd_core-2023.12.1/tests/decoder_waveform/test_decoder.py +0 -34
  79. shepherd_core-2023.12.1/tests/fw_tools/__init__.py +0 -0
  80. shepherd_core-2023.12.1/tests/fw_tools/conftest.py +0 -5
  81. shepherd_core-2023.12.1/tests/fw_tools/test_converter.py +0 -76
  82. shepherd_core-2023.12.1/tests/fw_tools/test_patcher.py +0 -66
  83. shepherd_core-2023.12.1/tests/fw_tools/test_validation.py +0 -56
  84. shepherd_core-2023.12.1/tests/inventory/__init__.py +0 -0
  85. shepherd_core-2023.12.1/tests/inventory/test_inventory.py +0 -20
  86. shepherd_core-2023.12.1/tests/testbed_client/__init__.py +0 -0
  87. shepherd_core-2023.12.1/tests/vsource/__init__.py +0 -0
  88. shepherd_core-2023.12.1/tests/vsource/conftest.py +0 -49
  89. shepherd_core-2023.12.1/tests/vsource/test_converter.py +0 -161
  90. shepherd_core-2023.12.1/tests/vsource/test_harvester.py +0 -73
  91. shepherd_core-2023.12.1/tests/vsource/test_z.py +0 -5
  92. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/calibration_hw_def.py +0 -0
  93. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/commons.py +0 -0
  94. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/__init__.py +0 -0
  95. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/base/__init__.py +0 -0
  96. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/base/cal_measurement.py +0 -0
  97. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/base/timezone.py +0 -0
  98. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/base/wrapper.py +0 -0
  99. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/content/__init__.py +0 -0
  100. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/content/firmware.py +0 -0
  101. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/content/firmware_datatype.py +0 -0
  102. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/doc_virtual_source.py +0 -0
  103. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/experiment/__init__.py +0 -0
  104. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/experiment/target_config.py +0 -0
  105. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/task/__init__.py +0 -0
  106. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/task/emulation.py +0 -0
  107. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/task/firmware_mod.py +0 -0
  108. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/task/harvest.py +0 -0
  109. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/task/programming.py +0 -0
  110. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/data_models/testbed/__init__.py +0 -0
  111. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/decoder_waveform/__init__.py +0 -0
  112. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/fw_tools/__init__.py +0 -0
  113. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/fw_tools/converter.py +0 -0
  114. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/fw_tools/converter_elf.py +0 -0
  115. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/fw_tools/patcher.py +0 -0
  116. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/inventory/python.py +0 -0
  117. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/inventory/target.py +0 -0
  118. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/logger.py +0 -0
  119. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/testbed_client/__init__.py +0 -0
  120. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core/vsource/__init__.py +0 -0
  121. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core.egg-info/dependency_links.txt +0 -0
  122. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core.egg-info/requires.txt +1 -1
  123. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/shepherd_core.egg-info/zip-safe +0 -0
  124. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/tests/test_cal_hw.py +0 -0
  125. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/tests/test_logger.py +0 -0
  126. {shepherd_core-2023.12.1 → shepherd_core-2024.4.1}/tests/test_reader.py +0 -0
@@ -1,14 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: shepherd_core
3
- Version: 2023.12.1
3
+ Version: 2024.4.1
4
4
  Summary: Programming- and CLI-Interface for the h5-dataformat of the Shepherd-Testbed
5
- Home-page: https://pypi.org/project/shepherd-core/
6
- Author: Ingmar Splitt, Kai Geissdoerfer
7
- Author-email: ingmar.splitt@tu-dresden.de
8
- Maintainer-email: ingmar.splitt@tu-dresden.de
9
- License: MIT
10
- Project-URL: Tracker, https://github.com/orgua/shepherd-datalib/issues
11
- Project-URL: Source, https://github.com/orgua/shepherd-datalib
5
+ Author-email: Ingmar Splitt <ingmar.splitt@tu-dresden.de>
6
+ Maintainer-email: Ingmar Splitt <ingmar.splitt@tu-dresden.de>
7
+ Project-URL: Documentation, https://github.com/orgua/shepherd-datalib/blob/main/README.md
8
+ Project-URL: Issues, https://github.com/orgua/shepherd-datalib/issues
9
+ Project-URL: Source, https://pypi.org/project/shepherd-core/
12
10
  Keywords: testbed,beaglebone,pru,batteryless,energyharvesting,solar
13
11
  Platform: unix
14
12
  Platform: linux
@@ -35,8 +33,8 @@ Requires-Dist: numpy
35
33
  Requires-Dist: pyYAML
36
34
  Requires-Dist: chromalog
37
35
  Requires-Dist: pydantic[email]>2.0.0
38
- Requires-Dist: tqdm
39
36
  Requires-Dist: scipy
37
+ Requires-Dist: tqdm
40
38
  Requires-Dist: intelhex
41
39
  Requires-Dist: requests
42
40
  Requires-Dist: pyelftools
@@ -63,7 +61,7 @@ Requires-Dist: coverage; extra == "test"
63
61
  [![Pytest](https://github.com/orgua/shepherd-datalib/actions/workflows/py_unittest.yml/badge.svg)](https://github.com/orgua/shepherd-datalib/actions/workflows/py_unittest.yml)
64
62
  [![CodeStyle](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
65
63
 
66
- **Documentation**: <https://orgua.github.io/shepherd/external/shepherd_core.html>
64
+ **Main Documentation**: <https://orgua.github.io/shepherd>
67
65
 
68
66
  **Source Code**: <https://github.com/orgua/shepherd-datalib>
69
67
 
@@ -71,53 +69,42 @@ Requires-Dist: coverage; extra == "test"
71
69
 
72
70
  ---
73
71
 
74
- This Python Module is designed as a library and bundles data-models and file-access-routines for the shepherd-testbed, that are used by several codebases.
72
+ `shepherd-core` is designed as a library and bundles data-models and file-access-routines for the shepherd-testbed, that are used by several codebases.
75
73
 
76
- For postprocessing shepherds .h5-files users want to use [shepherd_data](https://pypi.org/project/shepherd_data).
74
+ For postprocessing shepherds .h5-files usage of [shepherd_data](https://pypi.org/project/shepherd_data) is recommended.
77
75
 
78
76
  ## Features
79
77
 
80
78
  - read and write shepherds hdf5-files
81
- - create, read, write and convert experiments for the testbed (all data-models included)
79
+ - create, read, write and convert experiments for the testbed
80
+ - all required data-models are included
82
81
  - simulate the virtual source, including virtual harvesters (and virtual converter as a whole)
83
- - connect and query the testbed via a webclient (TestbedClient)
82
+ - connect and query the testbed via a webclient (TestbedClient in alpha-stage)
84
83
  - offline usage defaults to static demo-fixtures loaded from yaml-files in the model-directories
85
84
  - work with target-firmwares
86
85
  - embed, modify, verify, convert
87
86
  - **Note**: working with ELF-files requires external dependencies, see ``Installation``-Chapter
88
87
  - decode waveforms (gpio-state & timestamp) to UART
89
- - create an inventory (used versions of software, hardware)
88
+ - create an inventory (for deployed versions of software, hardware)
90
89
 
91
- See [examples](https://github.com/orgua/shepherd-datalib/tree/main/shepherd_core/examples) for more details and usage. Most functionality is showcased there. The [extra](https://github.com/orgua/shepherd-datalib/tree/main/shepherd_core/extra)-directory holds data-generators relevant for the testbed. Notably is a trafficbench-experiment that's used to derive the link-matrix.
90
+ See [official documentation](https://orgua.github.io/shepherd) or [example scripts](https://github.com/orgua/shepherd-datalib/tree/main/shepherd_core/examples) for more details and usage. Most functionality is showcased in both. The [extra](https://github.com/orgua/shepherd-datalib/tree/main/shepherd_core/extra)-directory holds data-generators relevant for the testbed. Notably is a [trafficbench](https://github.com/orgua/TrafficBench)-experiment that's used to derive the link-matrix of the testbed-nodes.
92
91
 
93
- ### Compatibility
92
+ ## Config-Models in Detail
94
93
 
95
- | OS | PyVersion | Comment |
96
- |---------|--------------|--------------------------------------------|
97
- | Ubuntu | 3.8 - 3.12 | |
98
- | Windows | 3.8 - 3.12 | no support for elf and hex-conversions yet |
99
- | MacOS | 3.8 - 3.12 | hex-conversion missing |
94
+ These pydantic data-models are used throughout all shepherd interfaces. Users can create an experiment, include their own content and feed it to the testbed.
100
95
 
101
- Notes:
102
- - hex-conversion needs a working and accessible objcopy
103
- - elf-supports needs
104
- - ``shepherd-core[elf]`` installs ``pwntools-elf-only``
105
- - most elf-features also still utilize hex-conversion
106
-
107
- ### Data-Models in Detail
108
-
109
- - new orchestration ``/data-models`` with focus on remote shepherd-testbed
96
+ - orchestration ``/data-models`` with focus on remote shepherd-testbed
110
97
  - classes of sub-models
111
98
  - ``/base``: base-classes, configuration and -functionality for all models
112
99
  - ``/testbed``: meta-data representation of all testbed-components
113
- - ``/content``: reusable meta-data for fw, h5 and vsrc-definitions
100
+ - ``/content``: reusable user-defined meta-data for fw, h5 and vsrc-definitions
114
101
  - ``/experiment``: configuration-models including sub-systems
115
102
  - ``/task``: digestible configs for shepherd-herd or -sheep
116
103
  - behavior controlled by ``ShpModel`` and ``content``-model
117
104
  - a basic database is available as fixtures through a ``tb_client``
118
105
  - fixtures selectable by name & ID
119
106
  - fixtures support inheritance
120
- - models support
107
+ - the models support
121
108
  - auto-completion with neutral / sensible values
122
109
  - complex and custom datatypes (i.e. PositiveInt, lists-checks on length)
123
110
  - checking of inputs and type-casting
@@ -130,6 +117,20 @@ Notes:
130
117
  - exposes no internal paths
131
118
  - experiments can be transformed to task-sets (``TestbedTasks.from_xp()``)
132
119
 
120
+ ## Compatibility
121
+
122
+ | OS | PyVersion | Comment |
123
+ |---------|--------------|--------------------------------------------|
124
+ | Ubuntu | 3.8 - 3.12 | |
125
+ | Windows | 3.8 - 3.12 | no support for elf and hex-conversions yet |
126
+ | MacOS | 3.8 - 3.12 | hex-conversion missing |
127
+
128
+ Notes:
129
+ - hex-conversion needs a working and accessible objcopy
130
+ - elf-supports needs
131
+ - ``shepherd-core[elf]`` installs ``pwntools-elf-only``
132
+ - most elf-features also still utilize hex-conversion
133
+
133
134
  ## Installation
134
135
 
135
136
  The Library is available via PyPI and can be installed with
@@ -166,3 +167,17 @@ For creating an inventory of the host-system you should install
166
167
  ```shell
167
168
  pip install shepherd-core[inventory]
168
169
  ```
170
+
171
+ ## Unittests
172
+
173
+ To run the testbench, follow these steps:
174
+
175
+ 1. Navigate your host-shell into the package-folder and
176
+ 2. install dependencies
177
+ 3. run the testbench (~ 320 tests):
178
+
179
+ ```Shell
180
+ cd shepherd-datalib/shepherd_core
181
+ pip3 install ./[tests]
182
+ pytest
183
+ ```
@@ -5,7 +5,7 @@
5
5
  [![Pytest](https://github.com/orgua/shepherd-datalib/actions/workflows/py_unittest.yml/badge.svg)](https://github.com/orgua/shepherd-datalib/actions/workflows/py_unittest.yml)
6
6
  [![CodeStyle](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
7
7
 
8
- **Documentation**: <https://orgua.github.io/shepherd/external/shepherd_core.html>
8
+ **Main Documentation**: <https://orgua.github.io/shepherd>
9
9
 
10
10
  **Source Code**: <https://github.com/orgua/shepherd-datalib>
11
11
 
@@ -13,53 +13,42 @@
13
13
 
14
14
  ---
15
15
 
16
- This Python Module is designed as a library and bundles data-models and file-access-routines for the shepherd-testbed, that are used by several codebases.
16
+ `shepherd-core` is designed as a library and bundles data-models and file-access-routines for the shepherd-testbed, that are used by several codebases.
17
17
 
18
- For postprocessing shepherds .h5-files users want to use [shepherd_data](https://pypi.org/project/shepherd_data).
18
+ For postprocessing shepherds .h5-files usage of [shepherd_data](https://pypi.org/project/shepherd_data) is recommended.
19
19
 
20
20
  ## Features
21
21
 
22
22
  - read and write shepherds hdf5-files
23
- - create, read, write and convert experiments for the testbed (all data-models included)
23
+ - create, read, write and convert experiments for the testbed
24
+ - all required data-models are included
24
25
  - simulate the virtual source, including virtual harvesters (and virtual converter as a whole)
25
- - connect and query the testbed via a webclient (TestbedClient)
26
+ - connect and query the testbed via a webclient (TestbedClient in alpha-stage)
26
27
  - offline usage defaults to static demo-fixtures loaded from yaml-files in the model-directories
27
28
  - work with target-firmwares
28
29
  - embed, modify, verify, convert
29
30
  - **Note**: working with ELF-files requires external dependencies, see ``Installation``-Chapter
30
31
  - decode waveforms (gpio-state & timestamp) to UART
31
- - create an inventory (used versions of software, hardware)
32
+ - create an inventory (for deployed versions of software, hardware)
32
33
 
33
- See [examples](https://github.com/orgua/shepherd-datalib/tree/main/shepherd_core/examples) for more details and usage. Most functionality is showcased there. The [extra](https://github.com/orgua/shepherd-datalib/tree/main/shepherd_core/extra)-directory holds data-generators relevant for the testbed. Notably is a trafficbench-experiment that's used to derive the link-matrix.
34
+ See [official documentation](https://orgua.github.io/shepherd) or [example scripts](https://github.com/orgua/shepherd-datalib/tree/main/shepherd_core/examples) for more details and usage. Most functionality is showcased in both. The [extra](https://github.com/orgua/shepherd-datalib/tree/main/shepherd_core/extra)-directory holds data-generators relevant for the testbed. Notably is a [trafficbench](https://github.com/orgua/TrafficBench)-experiment that's used to derive the link-matrix of the testbed-nodes.
34
35
 
35
- ### Compatibility
36
+ ## Config-Models in Detail
36
37
 
37
- | OS | PyVersion | Comment |
38
- |---------|--------------|--------------------------------------------|
39
- | Ubuntu | 3.8 - 3.12 | |
40
- | Windows | 3.8 - 3.12 | no support for elf and hex-conversions yet |
41
- | MacOS | 3.8 - 3.12 | hex-conversion missing |
42
-
43
- Notes:
44
- - hex-conversion needs a working and accessible objcopy
45
- - elf-supports needs
46
- - ``shepherd-core[elf]`` installs ``pwntools-elf-only``
47
- - most elf-features also still utilize hex-conversion
48
-
49
- ### Data-Models in Detail
38
+ These pydantic data-models are used throughout all shepherd interfaces. Users can create an experiment, include their own content and feed it to the testbed.
50
39
 
51
- - new orchestration ``/data-models`` with focus on remote shepherd-testbed
40
+ - orchestration ``/data-models`` with focus on remote shepherd-testbed
52
41
  - classes of sub-models
53
42
  - ``/base``: base-classes, configuration and -functionality for all models
54
43
  - ``/testbed``: meta-data representation of all testbed-components
55
- - ``/content``: reusable meta-data for fw, h5 and vsrc-definitions
44
+ - ``/content``: reusable user-defined meta-data for fw, h5 and vsrc-definitions
56
45
  - ``/experiment``: configuration-models including sub-systems
57
46
  - ``/task``: digestible configs for shepherd-herd or -sheep
58
47
  - behavior controlled by ``ShpModel`` and ``content``-model
59
48
  - a basic database is available as fixtures through a ``tb_client``
60
49
  - fixtures selectable by name & ID
61
50
  - fixtures support inheritance
62
- - models support
51
+ - the models support
63
52
  - auto-completion with neutral / sensible values
64
53
  - complex and custom datatypes (i.e. PositiveInt, lists-checks on length)
65
54
  - checking of inputs and type-casting
@@ -72,6 +61,20 @@ Notes:
72
61
  - exposes no internal paths
73
62
  - experiments can be transformed to task-sets (``TestbedTasks.from_xp()``)
74
63
 
64
+ ## Compatibility
65
+
66
+ | OS | PyVersion | Comment |
67
+ |---------|--------------|--------------------------------------------|
68
+ | Ubuntu | 3.8 - 3.12 | |
69
+ | Windows | 3.8 - 3.12 | no support for elf and hex-conversions yet |
70
+ | MacOS | 3.8 - 3.12 | hex-conversion missing |
71
+
72
+ Notes:
73
+ - hex-conversion needs a working and accessible objcopy
74
+ - elf-supports needs
75
+ - ``shepherd-core[elf]`` installs ``pwntools-elf-only``
76
+ - most elf-features also still utilize hex-conversion
77
+
75
78
  ## Installation
76
79
 
77
80
  The Library is available via PyPI and can be installed with
@@ -108,3 +111,17 @@ For creating an inventory of the host-system you should install
108
111
  ```shell
109
112
  pip install shepherd-core[inventory]
110
113
  ```
114
+
115
+ ## Unittests
116
+
117
+ To run the testbench, follow these steps:
118
+
119
+ 1. Navigate your host-shell into the package-folder and
120
+ 2. install dependencies
121
+ 3. run the testbench (~ 320 tests):
122
+
123
+ ```Shell
124
+ cd shepherd-datalib/shepherd_core
125
+ pip3 install ./[tests]
126
+ pytest
127
+ ```
@@ -0,0 +1,112 @@
1
+ [project]
2
+ name = "shepherd_core"
3
+ description = "Programming- and CLI-Interface for the h5-dataformat of the Shepherd-Testbed"
4
+ keywords = ["testbed", "beaglebone", "pru", "batteryless", "energyharvesting", "solar"]
5
+
6
+ authors = [{name = "Ingmar Splitt", email = "ingmar.splitt@tu-dresden.de"},]
7
+ maintainers = [{name = "Ingmar Splitt", email = "ingmar.splitt@tu-dresden.de"},]
8
+
9
+ readme = {file = "README.md", content-type = "text/markdown"}
10
+ license = {file = "LICENSE"}
11
+ dynamic = ["version"]
12
+
13
+ classifiers = [
14
+ "Development Status :: 5 - Production/Stable",
15
+ "Intended Audience :: Developers",
16
+ "Intended Audience :: Information Technology",
17
+ "Intended Audience :: Science/Research",
18
+ "Programming Language :: Python :: 3.8",
19
+ "Programming Language :: Python :: 3.9",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "License :: OSI Approved :: MIT License",
24
+ "Operating System :: OS Independent",
25
+ "Natural Language :: English",
26
+ ]
27
+
28
+ requires-python = ">=3.8"
29
+ dependencies = [
30
+ "h5py",
31
+ "numpy",
32
+ "pyYAML",
33
+ "chromalog",
34
+ "pydantic[email]>2.0.0",
35
+ "scipy",
36
+ "tqdm",
37
+ "intelhex",
38
+ "requests",
39
+ "pyelftools",
40
+ "zstandard",
41
+ ]
42
+
43
+ [project.optional-dependencies]
44
+ elf = [
45
+ "pwntools-elf-only",
46
+ # TODO: still separate because of missing windows-compat
47
+ # modified package for reading ELF-files with fw_tools
48
+ # original can be problematic to install on windows & beaglebone
49
+ # probably also needed: https://docs.pwntools.com/en/stable/install.html + binutils-$ARCH
50
+ ]
51
+
52
+ inventory = [
53
+ "psutil",
54
+ ]
55
+
56
+
57
+ dev = [
58
+ "twine",
59
+ "pre-commit",
60
+ "pyright",
61
+ "ruff",
62
+ "mypy",
63
+ "types-PyYAML",
64
+ ]
65
+
66
+ test = [
67
+ "pytest",
68
+ "coverage",
69
+ ]
70
+
71
+ [project.urls]
72
+ Documentation = "https://github.com/orgua/shepherd-datalib/blob/main/README.md"
73
+ Issues = "https://github.com/orgua/shepherd-datalib/issues"
74
+ Source = "https://pypi.org/project/shepherd-core/"
75
+
76
+ [build-system]
77
+ requires = ["setuptools"]
78
+ build-backend = "setuptools.build_meta"
79
+
80
+ [tool.setuptools]
81
+ platforms = ["unix", "linux", "osx", "cygwin", "win32", "win64"]
82
+ zip-safe = true
83
+ include-package-data = true
84
+
85
+ [tool.setuptools.package-dir]
86
+ shepherd_core = "shepherd_core"
87
+
88
+ [tool.setuptools.package-data]
89
+ shepherd_core = [
90
+ "README.md",
91
+ "*.yaml",
92
+ ]
93
+
94
+ [tool.setuptools.dynamic]
95
+ version = {attr = "shepherd_core.__version__"}
96
+
97
+ [tool.pytest.ini_options]
98
+ markers = [
99
+ "converter: automatically added when no objcopy is found (on ubuntu install build-essential)",
100
+ "elf: automatically added when no elf-support is found (on windows or missing shepherd-core[elf])"
101
+ ]
102
+
103
+ addopts = "-vvv --stepwise" # opts: verbose result for each tests
104
+ # TODO: add something like "--cov --cov-report html --cov-report term-missing --cov-fail-under 95"
105
+
106
+ [tool.coverage.run]
107
+ source = ["shepherd_core"]
108
+ omit = ["*/shepherd_data/*"]
109
+
110
+ [tool.mypy]
111
+ python_version = 3.8
112
+ ignore_missing_imports = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -4,6 +4,7 @@ Provides classes for storing and retrieving sampled IV data to/from
4
4
  HDF5 files.
5
5
 
6
6
  """
7
+
7
8
  from .data_models.base.calibration import Calc_t
8
9
  from .data_models.base.calibration import CalibrationCape
9
10
  from .data_models.base.calibration import CalibrationEmulator
@@ -12,7 +13,7 @@ from .data_models.base.calibration import CalibrationPair
12
13
  from .data_models.base.calibration import CalibrationSeries
13
14
  from .data_models.base.timezone import local_now
14
15
  from .data_models.base.timezone import local_tz
15
- from .data_models.task import Compression
16
+ from .data_models.task.emulation import Compression
16
17
  from .inventory import Inventory
17
18
  from .logger import get_verbose_level
18
19
  from .logger import increase_verbose_level
@@ -22,7 +23,7 @@ from .testbed_client.client import TestbedClient
22
23
  from .testbed_client.client import tb_client
23
24
  from .writer import Writer
24
25
 
25
- __version__ = "2023.12.1"
26
+ __version__ = "2024.04.1"
26
27
 
27
28
  __all__ = [
28
29
  "Reader",
@@ -165,7 +165,7 @@ class CapeData(ShpModel):
165
165
  `See<https://github.com/beagleboard/beaglebone-black/wiki/System-Reference-Manual#824_EEPROM_Data_Format>`_
166
166
  """
167
167
 
168
- header: conbytes(max_length=4) = b"\xAA\x55\x33\xEE"
168
+ header: conbytes(max_length=4) = b"\xaa\x55\x33\xee"
169
169
  eeprom_revision: constr(max_length=2) = "A2"
170
170
  board_name: constr(max_length=32) = "BeagleBone SHEPHERD2 Cape"
171
171
  version: constr(max_length=4) = "24B0"
@@ -207,6 +207,7 @@ class CalibrationCape(ShpModel):
207
207
  cape: data can be supplied
208
208
  Returns:
209
209
  CalibrationCape object with extracted calibration data.
210
+
210
211
  """
211
212
  dv = cls().model_dump(include={"harvester", "emulator"})
212
213
  lw = list(dict_generator(dv))
@@ -225,6 +226,7 @@ class CalibrationCape(ShpModel):
225
226
  Returns
226
227
  -------
227
228
  Byte string representation of calibration values.
229
+
228
230
  """
229
231
  lw = list(dict_generator(self.model_dump(include={"harvester", "emulator"})))
230
232
  values = [walk[-1] for walk in lw]
@@ -1,7 +1,10 @@
1
1
  import hashlib
2
2
  from datetime import datetime
3
3
  from typing import Optional
4
+ from typing import Union
5
+ from uuid import uuid4
4
6
 
7
+ from pydantic import UUID4
5
8
  from pydantic import Field
6
9
  from pydantic import StringConstraints
7
10
  from pydantic import model_validator
@@ -14,30 +17,34 @@ from .timezone import local_now
14
17
  # constr -> to_lower=True, max_length=16, regex=r"^[\w]+$"
15
18
  # ⤷ Regex = AlphaNum
16
19
  IdInt = Annotated[int, Field(ge=0, lt=2**128)]
17
- NameStr = Annotated[str, StringConstraints(max_length=32, pattern=r'^[^<>:;,?"*|\/\\]+$')]
20
+ NameStr = Annotated[str, StringConstraints(max_length=32, pattern=r"^[^<>:;,?\"\*|\/\\]+$")]
18
21
  # ⤷ Regex = FileSystem-Compatible ASCII
19
22
  SafeStr = Annotated[str, StringConstraints(pattern=r"^[ -~]+$")]
20
23
  # ⤷ Regex = All Printable ASCII-Characters with Space
21
24
 
22
25
 
23
26
  def id_default() -> int:
27
+ # note: IdInt has space for 128 bit, so 128/4 = 32 hex-chars
24
28
  time_stamp = str(local_now()).encode("utf-8")
25
- time_hash = hashlib.sha3_224(time_stamp).hexdigest()[-16:]
29
+ time_hash = hashlib.sha3_224(time_stamp).hexdigest()[-32:]
26
30
  return int(time_hash, 16)
27
31
 
28
32
 
29
33
  class ContentModel(ShpModel):
30
34
  # General Properties
31
- id: IdInt = Field( # noqa: A003
35
+ # id: UUID4 = Field( # TODO: db-migration - temp fix for documentation
36
+ id: Union[UUID4, int] = Field(
32
37
  description="Unique ID",
33
- default_factory=id_default,
38
+ default_factory=uuid4,
34
39
  )
35
40
  name: NameStr
36
41
  description: Annotated[Optional[SafeStr], Field(description="Required when public")] = None
37
42
  comment: Optional[SafeStr] = None
38
43
  created: datetime = Field(default_factory=datetime.now)
44
+ updated_last: datetime = Field(default_factory=datetime.now)
39
45
 
40
46
  # Ownership & Access
47
+ # TODO: remove owner & group, only needed for DB
41
48
  owner: NameStr
42
49
  group: Annotated[NameStr, Field(description="University or Subgroup")]
43
50
  visible2group: bool = False
@@ -7,6 +7,7 @@ from typing import Any
7
7
  from typing import Generator
8
8
  from typing import Optional
9
9
  from typing import Union
10
+ from uuid import UUID
10
11
 
11
12
  import yaml
12
13
  from pydantic import BaseModel
@@ -39,6 +40,7 @@ yaml.add_representer(pathlib.WindowsPath, path2str, SafeDumper)
39
40
  yaml.add_representer(pathlib.Path, path2str, SafeDumper)
40
41
  yaml.add_representer(timedelta, time2int, SafeDumper)
41
42
  yaml.add_representer(IPv4Address, generic2str, SafeDumper)
43
+ yaml.add_representer(UUID, generic2str, SafeDumper)
42
44
 
43
45
 
44
46
  class ShpModel(BaseModel):
@@ -13,7 +13,7 @@ class EnergyDType(str, Enum):
13
13
  ivsample = "ivsample"
14
14
  ivsamples = "ivsample"
15
15
  ivcurve = "ivcurve"
16
- ivcurves = "ivcurve"
16
+ ivcurves = "ivcurve" # a stream could also be called iv-surface
17
17
  isc_voc = "isc_voc"
18
18
 
19
19
 
@@ -76,7 +76,7 @@ class VirtualHarvesterConfig(ContentModel, title="Config for the Harvester"):
76
76
  logger.debug("VHrv-Inheritances: %s", chain)
77
77
 
78
78
  # post corrections -> should be in separate validator
79
- cal = CalibrationHarvester() # todo: as argument?
79
+ cal = CalibrationHarvester() # TODO: as argument?
80
80
  c_limit = values.get("current_limit_uA", 50_000) # cls.current_limit_uA)
81
81
  values["current_limit_uA"] = max(10**6 * cal.adc_C_Hrv.raw_to_si(4), c_limit)
82
82
 
@@ -25,12 +25,13 @@ class VirtualSourceConfig(ContentModel, title="Config for the virtual Source"):
25
25
  for supplying the Target Node during the experiment.
26
26
  If not already done, the energy will be harvested and then converted.
27
27
  The converter-stage is software defined and offers:
28
- buck-boost-combinations,
29
- a simple diode + resistor and
30
- an intermediate buffer capacitor.
31
- TODO: I,V,R should be in regular unit (V, A, Ohm)
28
+ - buck-boost-combinations,
29
+ - a simple diode + resistor and
30
+ - an intermediate buffer capacitor.
32
31
  """
33
32
 
33
+ # TODO: I,V,R should be in regular unit (V, A, Ohm)
34
+
34
35
  # General Metadata & Ownership -> ContentModel
35
36
 
36
37
  enable_boost: bool = False
@@ -123,14 +124,17 @@ class VirtualSourceConfig(ContentModel, title="Config for the virtual Source"):
123
124
  only has simpler formula, second enabling when V_Cap >= V_out
124
125
 
125
126
  Math behind this calculation:
126
- Energy-Change Storage Cap -> E_new = E_old - E_output
127
- with Energy of a Cap -> E_x = C_x * V_x^2 / 2
128
- combine formulas ->
129
- C_store * V_store_new^2 / 2 = C_store * V_store_old^2 / 2 - C_out * V_out^2 / 2
130
- convert formula to V_new -> V_store_new^2 = V_store_old^2 - (C_out / C_store) * V_out^2
131
- convert into dV -> dV = V_store_new - V_store_old
132
- in case of V_cap = V_out -> dV = V_store_old * (sqrt(1 - C_out / C_store) - 1)
133
- -> dV values will be reversed (negated), because dV is always negative (Voltage drop)
127
+
128
+ - Energy-Change Storage Cap -> E_new = E_old - E_output
129
+ - with Energy of a Cap -> E_x = C_x * V_x^2 / 2
130
+ - combine formulas -> C_store * V_store_new^2 / 2 =
131
+ C_store * V_store_old^2 / 2 - C_out * V_out^2 / 2
132
+ - convert formula to V_new -> V_store_new^2 =
133
+ V_store_old^2 - (C_out / C_store) * V_out^2
134
+ - convert into dV -> dV = V_store_new - V_store_old
135
+ - in case of V_cap = V_out -> dV = V_store_old * (sqrt(1 - C_out / C_store) - 1)
136
+
137
+ Note: dV values will be reversed (negated), because dV is always negative (Voltage drop)
134
138
  """
135
139
  values = {}
136
140
  if self.C_intermediate_uF > 0 and self.C_output_uF > 0:
@@ -186,8 +190,9 @@ class VirtualSourceConfig(ContentModel, title="Config for the virtual Source"):
186
190
 
187
191
  def calc_converter_mode(self, *, log_intermediate_node: bool) -> int:
188
192
  """Assembles bitmask from discrete values
193
+
189
194
  log_intermediate_node: record / log virtual intermediate (cap-)voltage and
190
- -current (out) instead of output-voltage and -current
195
+ -current (out) instead of output-voltage and -current
191
196
  """
192
197
  enable_storage = self.C_intermediate_uF > 0
193
198
  enable_boost = self.enable_boost and enable_storage
@@ -2,8 +2,10 @@ from datetime import datetime
2
2
  from datetime import timedelta
3
3
  from typing import List
4
4
  from typing import Optional
5
+ from typing import Union
6
+ from uuid import uuid4
5
7
 
6
- from pydantic import EmailStr
8
+ from pydantic import UUID4
7
9
  from pydantic import Field
8
10
  from pydantic import model_validator
9
11
  from typing_extensions import Annotated
@@ -12,7 +14,6 @@ from typing_extensions import Self
12
14
  from ..base.content import IdInt
13
15
  from ..base.content import NameStr
14
16
  from ..base.content import SafeStr
15
- from ..base.content import id_default
16
17
  from ..base.shepherd import ShpModel
17
18
  from ..testbed.target import Target
18
19
  from ..testbed.testbed import Testbed
@@ -26,11 +27,10 @@ class Experiment(ShpModel, title="Config of an Experiment"):
26
27
  """
27
28
 
28
29
  # General Properties
29
- id: IdInt = Field( # noqa: A003
30
- description="Unique ID",
31
- default_factory=id_default,
32
- )
30
+ # id: UUID4 ... # TODO db-migration - temp fix for documentation
31
+ id: Union[UUID4, int] = Field(default_factory=uuid4)
33
32
  # ⤷ TODO: automatic ID is problematic for identification by hash
33
+
34
34
  name: NameStr
35
35
  description: Annotated[
36
36
  Optional[SafeStr], Field(description="Required for public instances")
@@ -38,12 +38,12 @@ class Experiment(ShpModel, title="Config of an Experiment"):
38
38
  comment: Optional[SafeStr] = None
39
39
  created: datetime = Field(default_factory=datetime.now)
40
40
 
41
- # Ownership & Access, TODO
42
- owner_id: Optional[IdInt] = 5472 # UUID?
41
+ # Ownership & Access
42
+ owner_id: Optional[IdInt] = None
43
43
 
44
44
  # feedback
45
- email_results: Optional[EmailStr] = None
46
- # ⤷ TODO: can be bool, as its linked to account
45
+ email_results: bool = False
46
+
47
47
  sys_logging: SystemLogging = SystemLogging(dmesg=True, ptp=True, shepherd=True)
48
48
 
49
49
  # schedule
@@ -66,7 +66,7 @@ class GpioTracing(ShpModel, title="Config for GPIO-Tracing"):
66
66
 
67
67
  # post-processing,
68
68
  uart_decode: bool = False
69
- # todo: quickfix - uart-log currently done online in userspace
69
+ # TODO: quickfix - uart-log currently done online in userspace
70
70
  # NOTE: gpio-tracing currently shows rather big - but rare - "blind" windows (~1-4us)
71
71
  uart_pin: GPIO = GPIO(name="GPIO8")
72
72
  uart_baudrate: Annotated[int, Field(ge=2_400, le=921_600)] = 115_200
@@ -113,11 +113,10 @@ class GpioEvent(ShpModel, title="Config for a GPIO-Event"):
113
113
 
114
114
 
115
115
  class GpioActuation(ShpModel, title="Config for GPIO-Actuation"):
116
- """Configuration for a GPIO-Actuation-Sequence
117
- TODO: not implemented ATM:
118
- - decide if pru control sys-gpio or
119
- - reverses pru-gpio (preferred if possible)
120
- """
116
+ """Configuration for a GPIO-Actuation-Sequence"""
117
+
118
+ # TODO: not implemented ATM - decide if pru control sys-gpio or
119
+ # TODO: not implemented ATM - reverses pru-gpio (preferred if possible)
121
120
 
122
121
  events: Annotated[List[GpioEvent], Field(min_length=1, max_length=1024)]
123
122
 
@@ -21,7 +21,7 @@ class ObserverTasks(ShpModel):
21
21
  """Collection of tasks for selected observer included in experiment"""
22
22
 
23
23
  observer: NameStr
24
- owner_id: IdInt
24
+ owner_id: Optional[IdInt] # TODO: set to optional for now, shouldn't be
25
25
 
26
26
  # PRE PROCESS
27
27
  time_prep: datetime # TODO: should be optional