From b30ac3a7cc318a4c50a0e903393d0bcfbd0a8afa Mon Sep 17 00:00:00 2001 From: JieguangZhou Date: Wed, 18 Sep 2024 23:21:55 +0800 Subject: [PATCH 1/2] Fix compatibility issues with the latest version of pymongo --- CHANGELOG.md | 1 + plugins/mongodb/superduper_mongodb/data_backend.py | 1 + superduper/base/variables.py | 6 +++++- superduper/components/template.py | 13 +++++++++++-- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c47c99441..fd86bc329 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed default event.uuid - Fixed atlas vector search - Fix the bug where shared artifacts are deleted when removing a component. +- Fix compatibility issues with the latest version of pymongo. #### New Features & Functionality diff --git a/plugins/mongodb/superduper_mongodb/data_backend.py b/plugins/mongodb/superduper_mongodb/data_backend.py index 1fc493fa5..d040d34eb 100644 --- a/plugins/mongodb/superduper_mongodb/data_backend.py +++ b/plugins/mongodb/superduper_mongodb/data_backend.py @@ -4,6 +4,7 @@ import click import mongomock import pymongo +import pymongo.collection from superduper import CFG, logging from superduper.backends.base.data_backend import BaseDataBackend from superduper.backends.base.metadata import MetaDataStoreProxy diff --git a/superduper/base/variables.py b/superduper/base/variables.py index a5e3edb90..9dc3afc2a 100644 --- a/superduper/base/variables.py +++ b/superduper/base/variables.py @@ -23,7 +23,11 @@ def _replace_variables(x, **kwargs): _replace_variables(k, **kwargs): _replace_variables(v, **kwargs) for k, v in x.items() } - if isinstance(x, str) and re.match(r'^$', x) is not None and '<' not in x[1:-1]: + if ( + isinstance(x, str) + and re.match(r'^$', x) is not None + and '<' not in x[1:-1] + ): return kwargs.get(x[5:-1], x) if isinstance(x, str): variables = re.findall(r'', x) diff --git a/superduper/components/template.py b/superduper/components/template.py index 0704ce612..97e5181f8 100644 --- a/superduper/components/template.py +++ b/superduper/components/template.py @@ -23,6 +23,7 @@ class _BaseTemplate(Component): :param blobs: Blob identifiers in `Template.component`. :param files: File identifiers in `Template.component`. :param substitutions: Substitutions to be made to create variables. + :param default_values: Default values for the variables. """ literals: t.ClassVar[t.Tuple[str]] = ('template',) @@ -61,7 +62,11 @@ def form_template(self): return { 'identifier': '', '_variables': { - k: (f'' if k not in self.default_values else self.default_values[k]) + k: ( + f'' + if k not in self.default_values + else self.default_values[k] + ) for i, k in enumerate(self.template_variables) }, **{k: v for k, v in self.template.items() if k != 'identifier'}, @@ -187,7 +192,11 @@ def form_template(self): """Form to be diplayed to user.""" return { '_variables': { - k: (f'' if k not in self.default_values else self.default_values[k]) + k: ( + f'' + if k not in self.default_values + else self.default_values[k] + ) for i, k in enumerate(self.template_variables) }, **{ From 62234d4ff3f5f6852d1e2bea21c97541d29ab9a8 Mon Sep 17 00:00:00 2001 From: JieguangZhou Date: Wed, 18 Sep 2024 23:22:10 +0800 Subject: [PATCH 2/2] [PLUGINS] Bump Version [mongodb] --- plugins/mongodb/superduper_mongodb/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mongodb/superduper_mongodb/__init__.py b/plugins/mongodb/superduper_mongodb/__init__.py index 1b91265e4..ba779da86 100644 --- a/plugins/mongodb/superduper_mongodb/__init__.py +++ b/plugins/mongodb/superduper_mongodb/__init__.py @@ -3,7 +3,7 @@ from .metadata import MongoMetaDataStore as MetaDataStore from .query import MongoQuery -__version__ = "0.0.4" +__version__ = "0.0.5" __all__ = [ "ArtifactStore",