-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft: Enable new model id's #886
Draft
balthazur
wants to merge
14
commits into
main
Choose a base branch
from
new-model-ids
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+196
−137
Draft
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
359b19b
Init, wip
balthazur 4e98639
cleaning up the registry
balthazur e8947c7
remove unnecessary try catch
balthazur 5ca6b7d
cleaning up
balthazur cf33734
unit tests
balthazur 54a362c
pass workspace id as parameter to get model data
balthazur 40d9372
update tests
balthazur 724d881
cleanup prints
balthazur 4c4b381
remove required workspace id from api call
balthazur 74624f0
Merge branch 'main' into new-model-ids
balthazur 067fd24
Merge branch 'main' into new-model-ids
shantanubala 23d695c
Merge branch 'main' into new-model-ids
shantanubala 209e00f
Merge branch 'main' into new-model-ids
shantanubala a5c164d
Merge branch 'main' into new-model-ids
grzegorz-roboflow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
TaskType = str | ||
ModelType = str | ||
WorkspaceID = str | ||
ModelID = str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -225,13 +225,17 @@ def get_roboflow_model_data( | |||
("nocache", "true"), | ||||
("device", device_id), | ||||
("dynamic", "true"), | ||||
("type", endpoint_type.value), | ||||
("model", model_id), | ||||
] | ||||
if api_key is not None: | ||||
params.append(("api_key", api_key)) | ||||
api_url = _add_params_to_url( | ||||
url=f"{API_BASE_URL}/{endpoint_type.value}/{model_id}", | ||||
url=f"{API_BASE_URL}/getWeights", | ||||
params=params, | ||||
) | ||||
print("api_url", api_url) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Can delete this before merge. |
||||
|
||||
api_data = _get_from_url(url=api_url) | ||||
cache.set( | ||||
api_data_cache_key, | ||||
|
@@ -596,7 +600,9 @@ def get_from_url( | |||
|
||||
def _get_from_url(url: str, json_response: bool = True) -> Union[Response, dict]: | ||||
response = requests.get(wrap_url(url)) | ||||
|
||||
api_key_safe_raise_for_status(response=response) | ||||
|
||||
if json_response: | ||||
return response.json() | ||||
return response | ||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,35 @@ | ||
from typing import Tuple | ||
from typing import Optional, Tuple, Union | ||
|
||
from inference.core.entities.types import DatasetID, VersionID | ||
from inference.core.exceptions import InvalidModelIDError | ||
|
||
|
||
def get_model_id_chunks(model_id: str) -> Tuple[DatasetID, VersionID]: | ||
def get_model_id_chunks( | ||
model_id: str, | ||
) -> Union[Tuple[DatasetID, VersionID], Tuple[str, None]]: | ||
"""Parse a model ID into its components. | ||
|
||
Args: | ||
model_id (str): The model identifier, either in format "dataset/version" | ||
or a plain string for the new model IDs | ||
|
||
Returns: | ||
Union[Tuple[DatasetID, VersionID], Tuple[str, None]]: | ||
For traditional IDs: (dataset_id, version_id) | ||
For new string IDs: (model_id, None) | ||
|
||
Raises: | ||
InvalidModelIDError: If traditional model ID format is invalid | ||
""" | ||
if "/" not in model_id: | ||
# Handle new style model IDs that are just strings | ||
return model_id, None | ||
|
||
# Handle traditional dataset/version model IDs | ||
model_id_chunks = model_id.split("/") | ||
if len(model_id_chunks) != 2: | ||
raise InvalidModelIDError(f"Model ID: `{model_id}` is invalid.") | ||
raise InvalidModelIDError( | ||
f"Model ID: `{model_id}` is invalid. Expected format: 'dataset/version' or 'model_name'" | ||
) | ||
|
||
return model_id_chunks[0], model_id_chunks[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To answer this question, it seems like the version ID is primarily used in models like SAM where there are multiple versions of the foundation model that can be called. Everywhere else, it's mainly used for providing clear debug info.