Adedeji Ayinde

11/07/2022, 6:47 PM
Hi, is it possible to wrap a flyte task within a wrapper class implementation. When I tried calling the fit_classifier task from an object of the class I get an error message. Do you have any recommendation on how to wrap a flyte task in a class implementation?
class model_wrapper:
    def fit_classifier(self, train: pd.DataFrame,
                       val: pd.DataFrame) -> JoblibSerializedFile:

        # fetch the features and target columns from the train dataset
        x = train[train.columns[1:]]
        y = train[train.columns[0]]

        # fetch the features and target columns from the validation dataset
        eval_x = val[val.columns[1:]]
        eval_y = val[val.columns[0]]

        m = self.xgb_classifier()
        # fit the model to the train data, y, eval_set=[(eval_x, eval_y)])

        working_dir = flytekit.current_context().working_directory

        fname = os.path.join(working_dir, "model.joblib.dat")
        joblib.dump(m, fname)

        # return the serialized model
        return JoblibSerializedFile(path=fname)
Error message
raise _user_exceptions.FlyteAssertion("Input was not specified for: {} of type {}".format(k, var.type))
flytekit.exceptions.user.FlyteAssertion: Input was not specified for: self of type simple: NONE

Evan Sadler

11/07/2022, 7:11 PM
@Adedeji Ayinde we should sync tomorrow on what you want to do. There is probably a Flyte friendly alternative way to get what you want or a good opportunity to try UnionML, which is a conscience wrapper for ML Pipelines in Flyte.

Niels Bantilan

11/07/2022, 11:24 PM
I can help! You basically have to write a custom task resolver
would be happy to show off UnionML too of course, but also happy to talk through the more general solution if you want to roll your own task constructs

Evan Sadler

11/08/2022, 12:20 PM
Just for clarification…adedeji and I work together!
Learning about rolling our own task constructs would be really interesting

Niels Bantilan

11/08/2022, 3:54 PM
cool, lemme know if you want to set up a time to chat this week, you can invite me
@Evan Sadler @Adedeji Ayinde if you’re curious about how to write your own task resolvers you can join the UnionML OSS planning and we can discuss there! It’s at 12pm EST/9am PST if you can make it!