Models files#

Description#

This section deals with the files in the models folder.

These files are better formatted versions of the generated Python code from Flyte IDL. In the future, we hope to be able to improve the Python code generator sufficiently to avoid this manual work.

The only reason these files exist is because the Protobuf generated Python code doesn’t work well with IDEs. It doesn’t offer code completion, argument completion, docstrings, etc.

The structure of the code in the models folder should mirror the folder structure of the IDL. There are a few instances where this is not the case, but this is incidental.

Structure#

To get a sense of the Python model class structure, it may be helpful to take a look at an example like the TaskTemplate.

Constructor#

The constructor should allow specification of all the elements of the Protobuf object. Each element should be stored as an attribute with a leading underscore.

Properties#

Each element of the IDL message should be exposed as a property.

IDL interaction#

Each Python model class should have to_flyte_idl and from_flyte_idl functions that convert between the Python model class and the Protobuf-generated Python class.

Testing#

Please add unit tests to the tests/flytekit/unit/models folder to test the conversion logic.