Ejemplo n.º 1
0
    def execute(self, context):
        if 'name' not in self._version:
            self._version['name'] = self._version_name

        hook = MLEngineHook(gcp_conn_id=self._gcp_conn_id,
                            delegate_to=self._delegate_to)

        if self._operation == 'create':
            if not self._version:
                raise ValueError("version attribute of {} could not "
                                 "be empty".format(self.__class__.__name__))
            return hook.create_version(project_id=self._project_id,
                                       model_name=self._model_name,
                                       version_spec=self._version)
        elif self._operation == 'set_default':
            return hook.set_default_version(project_id=self._project_id,
                                            model_name=self._model_name,
                                            version_name=self._version['name'])
        elif self._operation == 'list':
            return hook.list_versions(project_id=self._project_id,
                                      model_name=self._model_name)
        elif self._operation == 'delete':
            return hook.delete_version(project_id=self._project_id,
                                       model_name=self._model_name,
                                       version_name=self._version['name'])
        else:
            raise ValueError('Unknown operation: {}'.format(self._operation))
Ejemplo n.º 2
0
    def execute(self, context):
        hook = MLEngineHook(gcp_conn_id=self._gcp_conn_id,
                            delegate_to=self._delegate_to)

        return hook.list_versions(
            project_id=self._project_id,
            model_name=self._model_name,
        )