Skip to content

Commit

Permalink
[PLUGINS] Bump Version [sqlalchemy]
Browse files Browse the repository at this point in the history
  • Loading branch information
blythed committed Jan 29, 2025
1 parent bf78247 commit 05f10c5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion plugins/sqlalchemy/superduper_sqlalchemy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .metadata import SQLAlchemyMetadata as MetaDataStore

__version__ = "0.5.2"
__version__ = "0.5.3"

__all__ = ['MetaDataStore']
23 changes: 17 additions & 6 deletions plugins/sqlalchemy/superduper_sqlalchemy/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
from superduper_sqlalchemy.db_helper import get_db_config


def wrap_underscore_path(data):
if 'superduper_path' in data:
data['_path'] = data.pop('superduper_path')
return data


def _connect_snowflake():
# In the Snowflake native apps framework, the
# inbuild database is provided by env variables
Expand Down Expand Up @@ -271,7 +277,7 @@ def _init_tables(self):
Column('hidden', type_boolean),
Column('status', type_string),
Column('type_id', type_string),
Column('_path', type_string),
Column('superduper_path', type_string),
Column('dict', type_json_as_text),
Column('cdc_table', type_string),
*component_table_args,
Expand Down Expand Up @@ -412,7 +418,7 @@ def _get_all_component_info(self):
select(self.component_table),
session=session,
)
return list(res)
return [wrap_underscore_path(r) for r in res]

def component_version_has_parents(
self, type_id: str, identifier: str, version: int
Expand Down Expand Up @@ -540,7 +546,7 @@ def get_component_by_uuid(self, uuid: str, allow_hidden: bool = False):
:param allow_hidden: whether to load hidden components
"""
if res := self._cache.get_metadata_by_uuid(uuid):
return res
return wrap_underscore_path(res)
with self.session_context() as session:
stmt = (
select(self.component_table)
Expand All @@ -555,6 +561,7 @@ def get_component_by_uuid(self, uuid: str, allow_hidden: bool = False):
try:
res = res[0]
res = self._cache.add_metadata(res)
res = wrap_underscore_path(res)
return res
except IndexError:
raise NonExistentMetadataError(
Expand All @@ -576,7 +583,7 @@ def _get_component(
:param allow_hidden: whether to allow hidden components
"""
if res := self._cache.get_metadata_by_identifier(type_id, identifier, version):
return res
return wrap_underscore_path(res)
with self.session_context() as session:
stmt = select(self.component_table).where(
self.component_table.c.type_id == type_id,
Expand All @@ -589,6 +596,7 @@ def _get_component(
res = self.query_results(self.component_table, stmt, session)
if res:
res = res[0]
res = wrap_underscore_path(res)
res = self._cache.add_metadata(res)
return res

Expand Down Expand Up @@ -621,6 +629,7 @@ def _refactor_component_info(cls, info):
new_info['dict'] = {k: info[k] for k in info if k not in component_fields}
new_info['id'] = new_info['dict']['uuid']
new_info['uuid'] = new_info['dict']['uuid']
new_info['superduper_path'] = new_info.pop('_path')
return new_info

def get_latest_version(
Expand Down Expand Up @@ -770,7 +779,7 @@ def _show_components(self, type_id: t.Optional[str] = None):
if type_id is not None:
stmt = stmt.where(self.component_table.c.type_id == type_id)
res = self.query_results(self.component_table, stmt, session)
return res
return [wrap_underscore_path(r) for r in res]

def show_component_versions(self, type_id: str, identifier: str):
"""Show all versions of a component in the database.
Expand All @@ -796,6 +805,8 @@ def _update_object(
value: t.Any,
version: int,
):
if key == '_path':
key = 'superduper_path'
with self.session_context() as session:
stmt = (
self.component_table.update()
Expand Down Expand Up @@ -926,4 +937,4 @@ def query_results(self, table, statment, session):
# - NotExist: SnowFlake returns error if a component does not exist
return []

return results
return [wrap_underscore_path(r) for r in results]

0 comments on commit 05f10c5

Please sign in to comment.