コード例 #1
0
ファイル: task.py プロジェクト: vglocus/flytekit
    def __init__(
        self,
        name: str,
        notebook_path: str,
        task_config: T = None,
        inputs: typing.Optional[typing.Dict[str, typing.Type]] = None,
        outputs: typing.Optional[typing.Dict[str, typing.Type]] = None,
        **kwargs,
    ):
        plugin_class = TaskPlugins.find_pythontask_plugin(type(task_config))
        self._plugin = plugin_class(task_config=task_config,
                                    task_function=_dummy_task_func)
        task_type = f"nb-{self._plugin.task_type}"
        self._notebook_path = os.path.abspath(notebook_path)

        if not os.path.exists(self._notebook_path):
            raise ValueError(
                f"Illegal notebook path passed in {self._notebook_path}")

        outputs.update({
            self._IMPLICIT_OP_NOTEBOOK:
            self._IMPLICIT_OP_NOTEBOOK_TYPE,
            self._IMPLICIT_RENDERED_NOTEBOOK:
            self._IMPLICIT_RENDERED_NOTEBOOK_TYPE,
        })
        super().__init__(name,
                         task_config,
                         task_type=task_type,
                         interface=Interface(inputs=inputs, outputs=outputs),
                         **kwargs)
コード例 #2
0
ファイル: task.py プロジェクト: flyteorg/flytekit
    def __init__(
        self,
        name: str,
        notebook_path: str,
        task_config: T = None,
        inputs: typing.Optional[typing.Dict[str, typing.Type]] = None,
        outputs: typing.Optional[typing.Dict[str, typing.Type]] = None,
        **kwargs,
    ):
        # Each instance of NotebookTask instantiates an underlying task with a dummy function that will only be used
        # to run pre- and post- execute functions using the corresponding task plugin.
        # We rename the function name here to ensure the generated task has a unique name and avoid duplicate task name
        # errors.
        # This seem like a hack. We should use a plugin_class that doesn't require a fake-function to make work.
        plugin_class = TaskPlugins.find_pythontask_plugin(type(task_config))
        self._config_task_instance = plugin_class(
            task_config=task_config, task_function=_dummy_task_func)
        # Rename the internal task so that there are no conflicts at serialization time. Technically these internal
        # tasks should not be serialized at all, but we don't currently have a mechanism for skipping Flyte entities
        # at serialization time.
        self._config_task_instance._name = f"{PAPERMILL_TASK_PREFIX}.{name}"
        task_type = f"nb-{self._config_task_instance.task_type}"
        self._notebook_path = os.path.abspath(notebook_path)

        if not os.path.exists(self._notebook_path):
            raise ValueError(
                f"Illegal notebook path passed in {self._notebook_path}")

        if outputs:
            outputs.update({
                self._IMPLICIT_OP_NOTEBOOK:
                self._IMPLICIT_OP_NOTEBOOK_TYPE,
                self._IMPLICIT_RENDERED_NOTEBOOK:
                self._IMPLICIT_RENDERED_NOTEBOOK_TYPE,
            })
        super().__init__(name,
                         task_config,
                         task_type=task_type,
                         interface=Interface(inputs=inputs, outputs=outputs),
                         **kwargs)