Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions label_studio_ml/api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from dagshub.mlflow import get_mlflow_model
from dagshub.data_engine import datasources
from dotenv import load_dotenv

Expand Down Expand Up @@ -60,7 +61,7 @@ def reverse_lookup(dictionary, target):
try:
uv_output = subprocess.run(f'yes | uv pip install --upgrade -r {req_path}', shell=True, capture_output=True)
except:
raise ValueError("Failed to install requirements.txt.")
raise RuntimeError("Failed to install requirements.txt.")
importlib.invalidate_caches()

lookup_table = importlib.metadata.packages_distributions()
Expand All @@ -72,10 +73,7 @@ def reverse_lookup(dictionary, target):
print(f"Could not re-load {module}")
importlib.invalidate_caches()

model_flavor = mlflow.models.get_model_info(model_uri).flavors['python_function']['loader_module']
loader = importlib.import_module(model_flavor[:len(model_flavor) - model_flavor[::-1].index('.') - 1])
mlflow_model = loader.load_model(model_uri, dst_path=tempdir)

mlflow_model = get_mlflow_model(args['repo'], args['name'], args['host'], args['version'])
ds = datasources.get_datasource(args['datasource_repo'], args['datasource_name'])
dp_map = ds.all().dataframe[['path', 'datapoint_id']]
model.configure(mlflow_model, *[cloudpickle.loads(base64.b64decode(args[hook])) for hook in ['pre_hook', 'post_hook']], ds, dp_map)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ semver~=3.0.2
label-studio-sdk==1.0.2
# label-studio-sdk @ git+https://github.com/HumanSignal/label-studio-sdk.git
python-dotenv==1.0.1
dagshub