save pickle in managed folder

Isma
Isma Registered Posts: 1 ✭✭✭
edited July 16 in Using Dataiku

Hello,

I want to save a picke object in DSS folder. Here is an example of working code outside DSS. How can I use the DSS API to do so in DSS.

def save_model(self
# Names
scope=self.scope.replace(' ', '_').lower()
model_name='model_' + scope
opt_tree_name='opt_tree_' + scope
pkl_name=model_name + '.pkl'
# Save pickles
with open(self.builds_path + pkl_name, 'wb') as f:
pickle.dump(self, f)

Answers

  • AlexandreL
    AlexandreL Dataiker, Registered Posts: 36 Dataiker
    edited July 17

    Hi,

    You can use the folder api to get a writer:

    with dataiku.Folder(FOLDER_ID).get_writer(MODEL_PATH_IN_FOLDER) as writer:
        writeable = pickle.dumps(MODEL)
        writer.write(writeable)

  • ssuhas76
    ssuhas76 Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Registered Posts: 31

    What if I need to do this in a endpioint code which runs outside of dataiku. I will have to used dataikuapi right? Do you know how this can be done?

Setup Info
    Tags
      Help me…