Skip to content

modules

Attributes

ONBOARDING_MODEL_NAME_PREFIX = 'onboarding.file.from.' module-attribute

Classes

OnboardFileConfig

Bases: KiaraModuleConfig

Source code in /opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/kiara_plugin/onboarding/modules/__init__.py
20
21
22
23
24
25
26
27
class OnboardFileConfig(KiaraModuleConfig):

    onboard_type: Union[None, str] = Field(
        description="The name of the type of onboarding.", default=None
    )
    attach_metadata: Union[bool, None] = Field(
        description="Whether to attach metadata.", default=None
    )

Attributes

onboard_type: Union[None, str] = Field(description='The name of the type of onboarding.', default=None) instance-attribute class-attribute
attach_metadata: Union[bool, None] = Field(description='Whether to attach metadata.', default=None) instance-attribute class-attribute

OnboardFileModule

Bases: KiaraModule

A generic module that imports a file from one of several possible sources.

Source code in /opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/kiara_plugin/onboarding/modules/__init__.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
class OnboardFileModule(KiaraModule):
    """A generic module that imports a file from one of several possible sources."""

    _module_type_name = "import.file"
    _config_cls = OnboardFileConfig

    def create_inputs_schema(
        self,
    ) -> ValueMapSchema:

        result = {
            "source": {
                "type": "string",
                "doc": "The source uri of the file to be onboarded.",
                "optional": False,
            },
            "file_name": {
                "type": "string",
                "doc": "The file name to use for the onboarded file (defaults to source file name if possible).",
                "optional": True,
            },
        }

        if self.get_config_value("attach_metadata") is None:
            result["attach_metadata"] = {
                "type": "boolean",
                "doc": "Whether to attach onboarding metadata to the result file.",
                "default": True,
            }

        onboard_type: Union[str, None] = self.get_config_value("onboard_type")
        if not onboard_type:
            onboard_model_cls = None
        else:
            onboard_model_cls = get_onboard_model_cls(onboard_type)

        if not onboard_model_cls:

            available = (
                ModelRegistry.instance()
                .get_models_of_type(OnboardDataModel)
                .item_infos.keys()
            )

            if not available:
                raise KiaraException(msg="No onboard models available. This is a bug.")

            idx = len(ONBOARDING_MODEL_NAME_PREFIX)
            allowed = sorted((x[idx:] for x in available))

            result["onboard_type"] = {
                "type": "string",
                "type_config": {"allowed_strings": allowed},
                "doc": "The type of onboarding to use. Allowed: {}".format(
                    ", ".join(allowed)
                ),
                "optional": True,
            }
        elif onboard_model_cls.get_config_fields():
            result = {
                "onboard_config": {
                    "type": "kiara_model",
                    "type_config": {
                        "kiara_model_id": self.get_config_value("onboard_type"),
                    },
                }
            }

        return result

    def create_outputs_schema(
        self,
    ) -> ValueMapSchema:

        result = {"file": {"type": "file", "doc": "The file that was onboarded."}}
        return result

    def process(self, inputs: ValueMap, outputs: ValueMap):

        onboard_type = self.get_config_value("onboard_type")

        source: str = inputs.get_value_data("source")
        file_name: Union[str, None] = inputs.get_value_data("file_name")

        if not onboard_type:

            user_input_onboard_type = inputs.get_value_data("onboard_type")
            if user_input_onboard_type:
                onboard_type = (
                    f"{ONBOARDING_MODEL_NAME_PREFIX}{user_input_onboard_type}"
                )

        attach_metadata = self.get_config_value("attach_metadata")
        if attach_metadata is None:
            attach_metadata = inputs.get_value_data("attach_metadata")

        data = onboard_file(
            source=source,
            file_name=file_name,
            onboard_type=onboard_type,
            attach_metadata=attach_metadata,
        )

        outputs.set_value("file", data)

Attributes

_config_cls = OnboardFileConfig instance-attribute class-attribute

Functions

create_inputs_schema() -> ValueMapSchema
Source code in /opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/kiara_plugin/onboarding/modules/__init__.py
 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
def create_inputs_schema(
    self,
) -> ValueMapSchema:

    result = {
        "source": {
            "type": "string",
            "doc": "The source uri of the file to be onboarded.",
            "optional": False,
        },
        "file_name": {
            "type": "string",
            "doc": "The file name to use for the onboarded file (defaults to source file name if possible).",
            "optional": True,
        },
    }

    if self.get_config_value("attach_metadata") is None:
        result["attach_metadata"] = {
            "type": "boolean",
            "doc": "Whether to attach onboarding metadata to the result file.",
            "default": True,
        }

    onboard_type: Union[str, None] = self.get_config_value("onboard_type")
    if not onboard_type:
        onboard_model_cls = None
    else:
        onboard_model_cls = get_onboard_model_cls(onboard_type)

    if not onboard_model_cls:

        available = (
            ModelRegistry.instance()
            .get_models_of_type(OnboardDataModel)
            .item_infos.keys()
        )

        if not available:
            raise KiaraException(msg="No onboard models available. This is a bug.")

        idx = len(ONBOARDING_MODEL_NAME_PREFIX)
        allowed = sorted((x[idx:] for x in available))

        result["onboard_type"] = {
            "type": "string",
            "type_config": {"allowed_strings": allowed},
            "doc": "The type of onboarding to use. Allowed: {}".format(
                ", ".join(allowed)
            ),
            "optional": True,
        }
    elif onboard_model_cls.get_config_fields():
        result = {
            "onboard_config": {
                "type": "kiara_model",
                "type_config": {
                    "kiara_model_id": self.get_config_value("onboard_type"),
                },
            }
        }

    return result
create_outputs_schema() -> ValueMapSchema
Source code in /opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/kiara_plugin/onboarding/modules/__init__.py
103
104
105
106
107
108
def create_outputs_schema(
    self,
) -> ValueMapSchema:

    result = {"file": {"type": "file", "doc": "The file that was onboarded."}}
    return result
process(inputs: ValueMap, outputs: ValueMap)
Source code in /opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/kiara_plugin/onboarding/modules/__init__.py
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
def process(self, inputs: ValueMap, outputs: ValueMap):

    onboard_type = self.get_config_value("onboard_type")

    source: str = inputs.get_value_data("source")
    file_name: Union[str, None] = inputs.get_value_data("file_name")

    if not onboard_type:

        user_input_onboard_type = inputs.get_value_data("onboard_type")
        if user_input_onboard_type:
            onboard_type = (
                f"{ONBOARDING_MODEL_NAME_PREFIX}{user_input_onboard_type}"
            )

    attach_metadata = self.get_config_value("attach_metadata")
    if attach_metadata is None:
        attach_metadata = inputs.get_value_data("attach_metadata")

    data = onboard_file(
        source=source,
        file_name=file_name,
        onboard_type=onboard_type,
        attach_metadata=attach_metadata,
    )

    outputs.set_value("file", data)

OnboardFileBundleConfig

Bases: KiaraModuleConfig

Source code in /opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/kiara_plugin/onboarding/modules/__init__.py
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
class OnboardFileBundleConfig(KiaraModuleConfig):

    onboard_type: Union[None, str] = Field(
        description="The name of the type of onboarding.", default=None
    )
    attach_metadata: Union[bool, None] = Field(
        description="Whether to attach onboarding metadata.", default=None
    )
    sub_path: Union[None, str] = Field(description="The sub path to use.", default=None)
    include_files: Union[None, List[str]] = Field(
        description="File types to include.", default=None
    )
    exclude_files: Union[None, List[str]] = Field(
        description="File types to include.", default=None
    )
    exclude_dirs: Union[None, List[str]] = Field(
        description="Exclude directories that end with one of those tokens.",
        default=None,
    )

Attributes

onboard_type: Union[None, str] = Field(description='The name of the type of onboarding.', default=None) instance-attribute class-attribute
attach_metadata: Union[bool, None] = Field(description='Whether to attach onboarding metadata.', default=None) instance-attribute class-attribute
sub_path: Union[None, str] = Field(description='The sub path to use.', default=None) instance-attribute class-attribute
include_files: Union[None, List[str]] = Field(description='File types to include.', default=None) instance-attribute class-attribute
exclude_files: Union[None, List[str]] = Field(description='File types to include.', default=None) instance-attribute class-attribute
exclude_dirs: Union[None, List[str]] = Field(description='Exclude directories that end with one of those tokens.', default=None) instance-attribute class-attribute

OnboardFileBundleModule

Bases: KiaraModule

A generic module that imports a file from one of several possible sources.

Source code in /opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/kiara_plugin/onboarding/modules/__init__.py
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
class OnboardFileBundleModule(KiaraModule):
    """A generic module that imports a file from one of several possible sources."""

    _module_type_name = "import.file_bundle"
    _config_cls = OnboardFileBundleConfig

    def create_inputs_schema(
        self,
    ) -> ValueMapSchema:

        result = {
            "source": {
                "type": "string",
                "doc": "The source uri of the file to be onboarded.",
                "optional": False,
            }
        }

        if self.get_config_value("attach_metadata") is None:
            result["attach_metadata"] = {
                "type": "boolean",
                "doc": "Whether to attach onboarding metadata.",
                "default": True,
            }
        if self.get_config_value("sub_path") is None:
            result["sub_path"] = {
                "type": "string",
                "doc": "The sub path to use. If not specified, the root of the source folder will be used.",
                "optional": True,
            }
        if self.get_config_value("include_files") is None:
            result["include_files"] = {
                "type": "list",
                "doc": "Include files that end with one of those tokens. If not specified, all file extensions are included.",
                "optional": True,
            }

        if self.get_config_value("exclude_files") is None:
            result["exclude_files"] = {
                "type": "list",
                "doc": "Exclude files that end with one of those tokens. If not specified, no file extensions are excluded.",
                "optional": True,
            }
        if self.get_config_value("exclude_dirs") is None:
            result["exclude_dirs"] = {
                "type": "list",
                "doc": "Exclude directories that end with one of those tokens. If not specified, no directories are excluded.",
                "optional": True,
            }

        onboard_type: Union[str, None] = self.get_config_value("onboard_type")
        if not onboard_type:
            onboard_model_cls = None
        else:
            onboard_model_cls = get_onboard_model_cls(onboard_type)

        if not onboard_model_cls:

            available = (
                ModelRegistry.instance()
                .get_models_of_type(OnboardDataModel)
                .item_infos.keys()
            )

            if not available:
                raise KiaraException(msg="No onboard models available. This is a bug.")

            idx = len(ONBOARDING_MODEL_NAME_PREFIX)
            allowed = sorted((x[idx:] for x in available))

            result["onboard_type"] = {
                "type": "string",
                "type_config": {"allowed_strings": allowed},
                "doc": "The type of onboarding to use. Allowed: {}".format(
                    ", ".join(allowed)
                ),
                "optional": True,
            }
        elif onboard_model_cls.get_config_fields():
            result = {
                "onboard_config": {
                    "type": "kiara_model",
                    "type_config": {
                        "kiara_model_id": self.get_config_value("onboard_type"),
                    },
                }
            }

        return result

    def create_outputs_schema(
        self,
    ) -> ValueMapSchema:

        result = {
            "file_bundle": {
                "type": "file_bundle",
                "doc": "The file_bundle that was onboarded.",
            }
        }
        return result

    def process(self, inputs: ValueMap, outputs: ValueMap):

        onboard_type = self.get_config_value("onboard_type")
        source: str = inputs.get_value_data("source")

        if onboard_type:
            user_input_onboard_type = inputs.get_value_data("onboard_type")
            if not user_input_onboard_type:
                onboard_type = (
                    f"{ONBOARDING_MODEL_NAME_PREFIX}{user_input_onboard_type}"
                )

        sub_path = self.get_config_value("sub_path")
        if sub_path is None:
            sub_path = inputs.get_value_data("sub_path")

        include = self.get_config_value("include_files")
        if include is None:
            _include = inputs.get_value_data("include_files")
            if _include:
                include = _include.list_data
        exclude = self.get_config_value("exclude_files")
        if exclude is None:
            _exclude = inputs.get_value_data("exclude_files")
            if _exclude:
                exclude = _exclude.list_data
        exclude_dirs = self.get_config_value("exclude_dirs")
        if exclude_dirs is None:
            _exclude_dirs = inputs.get_value_data("exclude_dirs")
            if _exclude_dirs:
                exclude_dirs = _exclude_dirs.list_data

        import_config_data = {
            "sub_path": sub_path,
        }
        if include:
            import_config_data["include_files"] = include
        if exclude:
            import_config_data["exclude_files"] = exclude
        if exclude_dirs:
            import_config_data["exclude_dirs"] = exclude_dirs

        import_config = FolderImportConfig(**import_config_data)
        attach_metadata = self.get_config_value("attach_metadata")
        if attach_metadata is None:
            attach_metadata = inputs.get_value_data("attach_metadata")

        imported_bundle = onboard_file_bundle(
            source=source,
            import_config=import_config,
            onboard_type=onboard_type,
            attach_metadata=attach_metadata,
        )

        outputs.set_value("file_bundle", imported_bundle)

Attributes

_config_cls = OnboardFileBundleConfig instance-attribute class-attribute

Functions

create_inputs_schema() -> ValueMapSchema
Source code in /opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/kiara_plugin/onboarding/modules/__init__.py
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
def create_inputs_schema(
    self,
) -> ValueMapSchema:

    result = {
        "source": {
            "type": "string",
            "doc": "The source uri of the file to be onboarded.",
            "optional": False,
        }
    }

    if self.get_config_value("attach_metadata") is None:
        result["attach_metadata"] = {
            "type": "boolean",
            "doc": "Whether to attach onboarding metadata.",
            "default": True,
        }
    if self.get_config_value("sub_path") is None:
        result["sub_path"] = {
            "type": "string",
            "doc": "The sub path to use. If not specified, the root of the source folder will be used.",
            "optional": True,
        }
    if self.get_config_value("include_files") is None:
        result["include_files"] = {
            "type": "list",
            "doc": "Include files that end with one of those tokens. If not specified, all file extensions are included.",
            "optional": True,
        }

    if self.get_config_value("exclude_files") is None:
        result["exclude_files"] = {
            "type": "list",
            "doc": "Exclude files that end with one of those tokens. If not specified, no file extensions are excluded.",
            "optional": True,
        }
    if self.get_config_value("exclude_dirs") is None:
        result["exclude_dirs"] = {
            "type": "list",
            "doc": "Exclude directories that end with one of those tokens. If not specified, no directories are excluded.",
            "optional": True,
        }

    onboard_type: Union[str, None] = self.get_config_value("onboard_type")
    if not onboard_type:
        onboard_model_cls = None
    else:
        onboard_model_cls = get_onboard_model_cls(onboard_type)

    if not onboard_model_cls:

        available = (
            ModelRegistry.instance()
            .get_models_of_type(OnboardDataModel)
            .item_infos.keys()
        )

        if not available:
            raise KiaraException(msg="No onboard models available. This is a bug.")

        idx = len(ONBOARDING_MODEL_NAME_PREFIX)
        allowed = sorted((x[idx:] for x in available))

        result["onboard_type"] = {
            "type": "string",
            "type_config": {"allowed_strings": allowed},
            "doc": "The type of onboarding to use. Allowed: {}".format(
                ", ".join(allowed)
            ),
            "optional": True,
        }
    elif onboard_model_cls.get_config_fields():
        result = {
            "onboard_config": {
                "type": "kiara_model",
                "type_config": {
                    "kiara_model_id": self.get_config_value("onboard_type"),
                },
            }
        }

    return result
create_outputs_schema() -> ValueMapSchema
Source code in /opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/kiara_plugin/onboarding/modules/__init__.py
250
251
252
253
254
255
256
257
258
259
260
def create_outputs_schema(
    self,
) -> ValueMapSchema:

    result = {
        "file_bundle": {
            "type": "file_bundle",
            "doc": "The file_bundle that was onboarded.",
        }
    }
    return result
process(inputs: ValueMap, outputs: ValueMap)
Source code in /opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/kiara_plugin/onboarding/modules/__init__.py
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
def process(self, inputs: ValueMap, outputs: ValueMap):

    onboard_type = self.get_config_value("onboard_type")
    source: str = inputs.get_value_data("source")

    if onboard_type:
        user_input_onboard_type = inputs.get_value_data("onboard_type")
        if not user_input_onboard_type:
            onboard_type = (
                f"{ONBOARDING_MODEL_NAME_PREFIX}{user_input_onboard_type}"
            )

    sub_path = self.get_config_value("sub_path")
    if sub_path is None:
        sub_path = inputs.get_value_data("sub_path")

    include = self.get_config_value("include_files")
    if include is None:
        _include = inputs.get_value_data("include_files")
        if _include:
            include = _include.list_data
    exclude = self.get_config_value("exclude_files")
    if exclude is None:
        _exclude = inputs.get_value_data("exclude_files")
        if _exclude:
            exclude = _exclude.list_data
    exclude_dirs = self.get_config_value("exclude_dirs")
    if exclude_dirs is None:
        _exclude_dirs = inputs.get_value_data("exclude_dirs")
        if _exclude_dirs:
            exclude_dirs = _exclude_dirs.list_data

    import_config_data = {
        "sub_path": sub_path,
    }
    if include:
        import_config_data["include_files"] = include
    if exclude:
        import_config_data["exclude_files"] = exclude
    if exclude_dirs:
        import_config_data["exclude_dirs"] = exclude_dirs

    import_config = FolderImportConfig(**import_config_data)
    attach_metadata = self.get_config_value("attach_metadata")
    if attach_metadata is None:
        attach_metadata = inputs.get_value_data("attach_metadata")

    imported_bundle = onboard_file_bundle(
        source=source,
        import_config=import_config,
        onboard_type=onboard_type,
        attach_metadata=attach_metadata,
    )

    outputs.set_value("file_bundle", imported_bundle)

Functions