Skip to content

[BUG] Task cannot return keras.Model - "Invalid filepath extension for saving." #6427

@HansBambel

Description

@HansBambel

Describe the bug

Following the example from https://www.union.ai/docs/flyte/user-guide/data-input-output/tensorflow/ I tried returning a keras.Model, but receive the following error due to a naming problem:

ValueError: Failed to convert outputs of task 'src.workflows.tutorial_example.train_model' at position 0.
    Failed to convert type <class 'keras.src.models.sequential.Sequential'> to type <class 'keras.src.models.model.Model'>.
    Error Message: Invalid filepath extension for saving. Please add either a `.keras` extension for the native Keras format (recommended) or a `.h5` extension. Use `model.export(filepath)` if you want to export a SavedModel for use with TFLite/TFServing/etc. Received: filepath=/tmp/flytek4ddfb4d/local_flytekit/6f804fd14418b087683c300d6a2547fe..

It seems that the path that flyte gives to keras' save function does not end with an allowed extension such as keras (which it can't infer anyway).

Is the workaround/fix to save the model and give back a folder/file instead? Then the docs should reflect that.

Expected behavior

To save the keras model as task output to feed it to another task.

Additional context to reproduce

  1. Follow tutorial from https://www.union.ai/docs/flyte/user-guide/data-input-output/tensorflow/ (only requires the train_model-function)
  2. Run the workflow

Screenshots

No response

Are you sure this issue hasn't been raised already?

  • Yes

Have you read the Code of Conduct?

  • Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocumentation-backloggedFor internal use. Reserved for community team workflow.priority/p1

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions