Slackbot
07/15/2023, 11:44 AMsauyon
07/18/2023, 12:46 AMget_label is something we create, maybe it's an issue on the model side?sauyon
07/18/2023, 12:48 AMget_label to a custom runner; see https://docs.bentoml.org/en/latest/concepts/runner.html#custom-runner.Nicolas Jaccard
07/18/2023, 8:16 AMRunner class. If I add it to the customer runner (inheriting Runnable), it doesn't find it in scope.sauyon
07/18/2023, 8:17 AMNicolas Jaccard
07/18/2023, 8:20 AMclass FastaiRunnable(bentoml.Runnable):
SUPPORTED_RESOURCES = ("cpu",)
SUPPORTS_CPU_MULTI_THREADING = True
def __init__(self):
MODEL_CLASSIFICATION = pipeline_info["models"]["fov_classification"]
artifact_file_classification = get_wandb_data(MODEL_CLASSIFICATION)
self.learner = load_learner(artifact_file_classification, cpu=True)
self.learner.eval()
print("FastaAI setup complete!")
@bentoml.Runnable.method(batchable=False)
def predict(self, input):
return self.learner.predict(np.asarray(input))
If I add get_label in FastaiRunnable, it can't find it in scope. As mentioned above, the only way I got it to find get_label in scope is to add it to bentoml_cli/worker/runner.py. I am probably missing something obvious 🙂sauyon
07/18/2023, 8:20 AMNicolas Jaccard
07/18/2023, 8:22 AMget_label cannot be found in the <local>...<Runner> scope (paraphrased). Hence why I even tried to add it to Runner in the first place.sauyon
07/18/2023, 8:25 AMsauyon
07/18/2023, 8:25 AMNicolas Jaccard
07/18/2023, 8:27 AM1.0.5 as this is what we currently have in production. Otherwise it might be a bug indeed!sauyon
07/18/2023, 8:28 AMsauyon
07/18/2023, 8:35 AM@bentoml.Runnable.method()
def get_label(self, label: str) -> str:
return "test" + label
fastai_runnable.get_label.run("label")Nicolas Jaccard
07/18/2023, 8:36 AMNicolas Jaccard
07/18/2023, 8:37 AMNicolas Jaccard
07/20/2023, 7:52 AMself (also tried without self).
AttributeError: Custom classes or functions exported with your `Learner` not available in namespace.\Re-declare/import before loading:
Can't get attribute 'get_label' on <module 'bentoml_cli.worker.runner' from '/usr/local/lib/python3.8/site-packages/bentoml_cli/worker/runner.py'>sauyon
07/21/2023, 7:37 PM