Skip to content

Instantly share code, notes, and snippets.

@tabsciy
Last active September 22, 2022 05:05
Show Gist options
  • Save tabsciy/8998b4a4f7bf42dcc7bea4806e44b954 to your computer and use it in GitHub Desktop.
Save tabsciy/8998b4a4f7bf42dcc7bea4806e44b954 to your computer and use it in GitHub Desktop.
hello world example with loaded state example 2
from Algorithmia import ADK
import Algorithmia
import pickle
client = Algorithmia.client()
def load_model(file_path):
model_path = client.file(file_path).getFile().name
with open(model_path, 'rb') as f:
model = pickle.load(f)
return model
# my_model.pkl is a dict with key 'metadata'
def load(modelData):
modelData['my_model'] = load_model('data://fws/test/my_model.pkl')
return modelData
def apply(input, modelData):
return "hello {} {}".format(str(input), str(modelData['my_model']['metadata']))
algorithm = ADK(apply, load)
algorithm.init("Algorithmia")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment