opensampl.create.create_vendor
Creating new vendors/clock probe types based on config files.
This module provides functionality to create new vendor types for the openSAMPL package based on YAML configuration files. It handles the generation of probe classes, metadata classes, and updates to the constants file.
Note
This module is in beta and may change in future versions.
DEFAULT_METADATA
Default metadata fields for vendor configurations.
Source code in opensampl/create/create_vendor.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
get_default_fields()
classmethod
Get list of default metadata fields.
Returns:
| Type | Description |
|---|---|
list[MetadataField]
|
List of MetadataField instances for default fields. |
Source code in opensampl/create/create_vendor.py
48 49 50 51 52 53 54 55 56 57 | |
MetadataField
Bases: BaseModel
Definition for a metadata field in the vendor config.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The name of the metadata field. |
sqlalchemy_type |
str | None
|
The SQLAlchemy type for the field (default: "Text"). |
primary_key |
bool | None
|
Whether this field is a primary key (default: False). |
Source code in opensampl/create/create_vendor.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
VendorConfig
Bases: VendorType
Configuration definition for a new vendor type.
Attributes:
| Name | Type | Description |
|---|---|---|
base_path |
Path
|
Base path for the openSAMPL package. |
Source code in opensampl/create/create_vendor.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
create(collect_mixin=False)
Create the new vendor by generating probe file, ORM class, and updating constants.
Source code in opensampl/create/create_vendor.py
244 245 246 247 248 | |
create_metadata_class()
Create the metadata class using template-based approach.
Returns:
| Type | Description |
|---|---|
str
|
String containing the ORM class definition. |
Source code in opensampl/create/create_vendor.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
create_orm_class()
Create the ORM metadata class in the database ORM file.
Source code in opensampl/create/create_vendor.py
225 226 227 228 229 | |
create_probe_file(collect_mixin=False)
Create a new probe class file.
Returns:
| Type | Description |
|---|---|
Path
|
Path to the created probe file. |
Source code in opensampl/create/create_vendor.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
from_config_file(config_path)
classmethod
Convert file config into Config object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
str | Path
|
Path to the YAML configuration file. |
required |
Returns:
| Type | Description |
|---|---|
VendorConfig
|
VendorConfig instance created from the file. |
Source code in opensampl/create/create_vendor.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
generate_default_fields(data)
classmethod
Generate default values for fields if they are not provided in the config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Raw configuration data. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Updated configuration data with default values. |
Source code in opensampl/create/create_vendor.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
generate_metadata_columns()
Generate the metadata column definitions for the ORM template.
Returns:
| Type | Description |
|---|---|
str
|
String containing formatted column definitions. |
Source code in opensampl/create/create_vendor.py
169 170 171 172 173 174 175 176 177 178 | |
insert_content_at_marker(marker, content)
staticmethod
Insert content at a specified marker in a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
marker
|
InsertMarker
|
InsertMarker defining where to insert content. |
required |
content
|
str
|
Content to insert at the marker location. |
required |
Source code in opensampl/create/create_vendor.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
update_constants()
Update the constants.py file with the new vendor type.
Source code in opensampl/create/create_vendor.py
231 232 233 234 235 236 237 238 239 240 241 242 | |