This section deals with the files in 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 only because the Protobuf generated Python code doesn’t work well with IDEs. It doesn’t offer code completion, doesn’t offer 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 and we’ll work on resolving these.
It may be helpful to take a look at an example like the
The constructor should allow specification of all the elements of the Protobuf object. They should be stored as an attribute with a leading underscore.
Each element of the IDL message should be exposed as a property.
Each Python object should have a
to_flyte_idl and a
from_flyte_idl function that converts between the Python model class and the Protobuf-generated Python class.
Please add unit tests to the
tests/flytekit/unit/models folder to test the conversion logic.