-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add TGISBackend.register_model_connection()
method
#55
Conversation
Signed-off-by: Mynhardt Burger <[email protected]>
Signed-off-by: Mynhardt Burger <[email protected]>
@gabe-l-hart FYI |
Signed-off-by: Mynhardt Burger <[email protected]>
Signed-off-by: Mynhardt Burger <[email protected]>
e90da79
to
e07bb87
Compare
Signed-off-by: Mynhardt Burger <[email protected]>
Signed-off-by: Mynhardt Burger <[email protected]>
Signed-off-by: Mynhardt Burger <[email protected]>
Signed-off-by: Mynhardt Burger <[email protected]>
Signed-off-by: Mynhardt Burger <[email protected]>
Signed-off-by: Mynhardt Burger <[email protected]>
Signed-off-by: Mynhardt Burger <[email protected]>
Signed-off-by: Mynhardt Burger <[email protected]>
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.
A few tiny NITs, but otherwise this looks great!
"""Create an instance from a connection template and a model_id""" | ||
hostname = config.get(cls.HOSTNAME_KEY) | ||
if hostname: | ||
hostname = hostname.format( | ||
**{ | ||
assert isinstance(hostname, str) |
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.
Let's use an error.type_check
here: https://github.com/caikit/caikit-tgis-backend/pull/55/files#diff-7ec3e3fe32d1c1cfeff9730bcc81b54236e2bf8ea37f63a8de33fc4be6359e67R43
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.
done.
tests/test_tgis_backend.py
Outdated
@@ -681,6 +680,103 @@ def test_tgis_backend_config_load_prompt_artifacts(): | |||
tgis_be.load_prompt_artifacts("buz", prompt_id1, source_files[0]) | |||
|
|||
|
|||
def test_tgis_backend_register_model_connection(): |
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.
You might be able to consolidate these two tests with @pytest.mark.parametrize
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.
done.
Signed-off-by: Mynhardt Burger <[email protected]>
Signed-off-by: Mynhardt Burger <[email protected]>
Signed-off-by: Mynhardt Burger <[email protected]>
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.
One little bug fix to avoid mutating the base connection dict
caikit_tgis_backend/tgis_backend.py
Outdated
new_conn_cfg = self._base_connection_cfg | ||
else: | ||
if fill_with_defaults: | ||
new_conn_cfg = self._base_connection_cfg |
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.
I think this needs to be self._base_connection_cfg.copy
otherwise the update
below will mutate self._base_connection_cfg
. Since there is nesting, it should actually probably be copy.deepcopy
.
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.
Good catch. fixed.
Signed-off-by: Mynhardt Burger <[email protected]>
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.
Looks great, thanks Mynhardt!
Added
TGISBackend.register_model_connection()
to allow for registering a newTGISConnection
model connection with either the default connection, a custom provided connection, or a mixture where the custom provided connection is enhanced by populating the missing settings with those from the default connection.If the connection already exists, it does nothing.
Additionally the following refactoring was done:
TGISBackend._test_connection()
TGISBackend._safely_update_state()
to ensure thread safe updates to the_model_connections
and_remote_models_cfg
dictionaries.