-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add ReadOnly APIs #4606
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
Merged
Merged
Add ReadOnly APIs #4606
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
084cd85
Add ReadOnly APIs
a995ef8
Resolving PR review comments
efb4f9e
Resolve PR review comments
97ee0c3
Refactoring
7f4d5a5
Refactoring
9575ab2
Add Caching
3f86bcd
Refactore
7773a51
Resolving conflicts
432f928
Merge branch 'master-benchmark-feature' into benchmark
makungaj1 be9bf89
Add Unit Tests
f1a7009
Fix Unit Tests
a3acd84
Fix unit tests
d35cfa5
Fix UT
8c728c7
Refactoring
4a3b476
Fix Integ tests
2aa927e
refactoring after Notebook testing
23bc62a
Fix code styles
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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -2154,3 +2154,93 @@ def __init__( | |
self.data_input_configuration = data_input_configuration | ||
self.skip_model_validation = skip_model_validation | ||
self.source_uri = source_uri | ||
|
||
|
||
class BaseDeploymentConfigDataHolder(JumpStartDataHolderType): | ||
"""Base class for Deployment Config Data.""" | ||
|
||
def _convert_to_pascal_case(self, attr_name: str) -> str: | ||
"""Converts a snake_case attribute name into a camelCased string.""" | ||
return attr_name.replace("_", " ").title().replace(" ", "") | ||
|
||
def to_json(self) -> Dict[str, Any]: | ||
"""Represents ``This`` object as JSON.""" | ||
json_obj = {} | ||
for att in self.__slots__: | ||
if hasattr(self, att): | ||
cur_val = getattr(self, att) | ||
att = self._convert_to_pascal_case(att) | ||
if issubclass(type(cur_val), JumpStartDataHolderType): | ||
json_obj[att] = cur_val.to_json() | ||
elif isinstance(cur_val, list): | ||
json_obj[att] = [] | ||
for obj in cur_val: | ||
if issubclass(type(obj), JumpStartDataHolderType): | ||
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. this logic's really complicated. if you can find a way to reduce indentation level, that'd improve readability |
||
json_obj[att].append(obj.to_json()) | ||
else: | ||
json_obj[att].append(obj) | ||
elif isinstance(cur_val, dict): | ||
json_obj[att] = {} | ||
for key, val in cur_val.items(): | ||
if issubclass(type(val), JumpStartDataHolderType): | ||
json_obj[att][self._convert_to_pascal_case(key)] = val.to_json() | ||
else: | ||
json_obj[att][key] = val | ||
else: | ||
json_obj[att] = cur_val | ||
return json_obj | ||
|
||
|
||
class DeploymentConfig(BaseDeploymentConfigDataHolder): | ||
"""Dataclass representing a Deployment Config.""" | ||
|
||
__slots__ = [ | ||
"model_data_download_timeout", | ||
"container_startup_health_check_timeout", | ||
"image_uri", | ||
"model_data", | ||
"instance_type", | ||
"environment", | ||
"compute_resource_requirements", | ||
] | ||
|
||
def __init__( | ||
self, init_kwargs: JumpStartModelInitKwargs, deploy_kwargs: JumpStartModelDeployKwargs | ||
): | ||
"""Instantiates DeploymentConfig object.""" | ||
if init_kwargs is not None: | ||
self.image_uri = init_kwargs.image_uri | ||
self.model_data = init_kwargs.model_data | ||
self.instance_type = init_kwargs.instance_type | ||
self.environment = init_kwargs.env | ||
if init_kwargs.resources is not None: | ||
self.compute_resource_requirements = ( | ||
init_kwargs.resources.get_compute_resource_requirements() | ||
) | ||
if deploy_kwargs is not None: | ||
self.model_data_download_timeout = deploy_kwargs.model_data_download_timeout | ||
self.container_startup_health_check_timeout = ( | ||
deploy_kwargs.container_startup_health_check_timeout | ||
) | ||
|
||
|
||
class DeploymentConfigMetadata(BaseDeploymentConfigDataHolder): | ||
"""Dataclass representing a Deployment Config Metadata""" | ||
|
||
__slots__ = [ | ||
"config_name", | ||
"benchmark_metrics", | ||
"deployment_config", | ||
] | ||
|
||
def __init__( | ||
self, | ||
config_name: str, | ||
benchmark_metrics: List[JumpStartBenchmarkStat], | ||
init_kwargs: JumpStartModelInitKwargs, | ||
deploy_kwargs: JumpStartModelDeployKwargs, | ||
): | ||
"""Instantiates DeploymentConfigMetadata object.""" | ||
self.config_name = config_name | ||
self.benchmark_metrics = benchmark_metrics | ||
self.deployment_config = DeploymentConfig(init_kwargs, deploy_kwargs) |
This file contains hidden or 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 hidden or 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 hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.