Exporters
cognite.neat._rules.exporters
#
DMSExporter
#
Bases: CDFExporter[DMSRules, DMSSchema]
Export rules to Cognite Data Fusion's Data Model Storage (DMS) service.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
export_components |
frozenset[Literal['all', 'spaces', 'data_models', 'views', 'containers']]
|
Which components to export. Defaults to frozenset({"all"}). |
'all'
|
include_space |
set[str]
|
If set, only export components in the given spaces. Defaults to None which means all spaces. |
None
|
existing_handling |
Literal['fail', 'skip', 'update', 'force']
|
How to handle existing components. Defaults to "update". See below for details. |
'update'
|
export_pipeline |
bool
|
Whether to export the pipeline. Defaults to False. This means setting up transformations, RAW databases and tables to populate the data model. |
False
|
instance_space |
str
|
The space to use for the instance. Defaults to None. |
None
|
suppress_warnings |
bool
|
Suppress warnings. Defaults to False. |
False
|
... note::
- "fail": If any component already exists, the export will fail.
- "skip": If any component already exists, it will be skipped.
- "update": If any component already exists, it will be updated.
- "force": If any component already exists, it will be deleted and recreated.
Source code in cognite/neat/_rules/exporters/_rules2dms.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
|
export_to_file(rules, filepath)
#
Export the rules to a file(s).
If the file is a directory, the components will be exported to separate files, otherwise they will be exported to a zip file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
Path
|
Directory or zip file path to export to. |
required |
rules |
DMSRules
|
|
required |
Source code in cognite/neat/_rules/exporters/_rules2dms.py
ExcelExporter
#
Bases: BaseExporter[VerifiedRules, Workbook]
Export rules to Excel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
styling |
Style
|
The styling to use for the Excel file. Defaults to "default". See below for details on the different styles. |
'default'
|
output_role |
The role to use for the exported spreadsheet. If provided, the rules will be converted to this role formate before being written to excel. If not provided, the role from the rules will be used. |
required | |
dump_as |
DumpOptions
|
This determines how the rules are written to the Excel file. An Excel file has up to three sets of sheets: user, last, and reference. The user sheets are used for inputting rules from a user. The last sheets are used for the last version of the same model as the user, while the reference sheets are used for the model the user is building on. The options are: * "user": The rules are written to the user sheets. This is used when you want to modify the rules directly and potentially change the model. This is useful when you have imported the data model from outside CDF and you want to modify it before you write it to CDF. * "last": The rules are written to the last sheets. This is used when you want to extend the rules, but have validation that you are not breaking the existing model. This is used when you want to change a model that has already been published to CDF and that model is in production. * "reference": The rules are written to the reference sheets. This is typically used when you want to build a new solution on top of an enterprise model. |
'user'
|
new_model_id |
tuple[str, str] | None
|
The new model ID to use for the exported spreadsheet. This is only applicable if the input rules have 'is_reference' set. If provided, the model ID will be used to automatically create the new metadata sheet in the Excel file. The model id is expected to be a tuple of (prefix, title) (space, external_id) for InformationRules and DMSRules respectively. |
None
|
The following styles are available:
- "none": No styling is applied.
- "minimal": Column widths are adjusted to fit the content, and the header row(s) is frozen.
- "default": Minimal + headers are bold, increased size, and colored.
- "maximal": Default + alternating row colors in the properties sheet for each class in addition to extra blank rows between classes and borders
Source code in cognite/neat/_rules/exporters/_rules2excel.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 249 250 251 252 253 254 255 256 257 258 259 |
|
export_to_file(rules, filepath)
#
Exports transformation rules to excel file.
InstanceTemplateExporter
#
Bases: BaseExporter[InformationRules, Workbook]
Converts Information Rules to a templated spreadsheet meant for capturing instances based on class definitions in the rules.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
no_rows |
int
|
number of rows for processing, by default 1000 |
1000
|
auto_identifier_type |
Literal['index', 'uuid']
|
type of automatic identifier, by default "index" based, alternative is "uuid" based |
'index'
|
add_drop_down_list |
bool
|
Add drop down selection for columns that contain linking properties, by default True |
True
|
no_rows parameter
no_rows should be set to the maximum expected number of instances of any of the classes. By default, it is set to 1000, increase it accordingly if you have more instances.
Source code in cognite/neat/_rules/exporters/_rules2instance_template.py
export_to_file(rules, filepath)
#
Exports graph capturing sheet to excel file.
Source code in cognite/neat/_rules/exporters/_rules2instance_template.py
OWLExporter
#
Bases: GraphExporter
Exports verified information rules to an OWL ontology.
Source code in cognite/neat/_rules/exporters/_rules2ontology.py
SemanticDataModelExporter
#
Bases: GraphExporter
Exports verified information rules to a semantic data model.
Source code in cognite/neat/_rules/exporters/_rules2ontology.py
SHACLExporter
#
Bases: GraphExporter
Exports rules to a SHACL graph.
Source code in cognite/neat/_rules/exporters/_rules2ontology.py
YAMLExporter
#
Bases: BaseExporter[VerifiedRules, str]
Export rules (Information, DMS or Domain) to YAML.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
files |
Files
|
The number of files to output. Defaults to "single". |
'single'
|
output |
Format
|
The format to output the rules. Defaults to "yaml". |
'yaml'
|
The following formats are available:
- "single": A single YAML file will contain the entire rules.
.. note::
YAML files are typically used for storing rules when checked into version control systems, e.g., git-history.
The advantage of using YAML files over Excel is that tools like git can show the differences between different
versions of the rules.
Source code in cognite/neat/_rules/exporters/_rules2yaml.py
export_to_file(rules, filepath)
#
Exports transformation rules to YAML/JSON file(s).
Source code in cognite/neat/_rules/exporters/_rules2yaml.py
export(rules)
#
Export rules to YAML (or JSON) format.
This will export the rules to YAML format if the output is set to "yaml" and JSON format if the output is set. All None and Unset values are excluded from the output to keep the output clean, i.e., only the values the user has set.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rules |
VerifiedRules
|
The rules to be exported. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The rules in YAML (or JSON) format. |