nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: CS-SI/eodag
Pull request #682 (2023-03-21 10:49:19)

fix: update external product types for unknown provider
Fixes issue when updating external product types for unknown provider


Patch:
diff --git a/eodag/api/core.py b/eodag/api/core.py
index 6d23d2c5..785d4ba3 100644
--- a/eodag/api/core.py
+++ b/eodag/api/core.py
@@ -682,7 +682,7 @@ class EODataAccessGateway(object):
         :type ext_product_types_conf: dict
         """
         for provider, new_product_types_conf in ext_product_types_conf.items():
-            if new_product_types_conf:
+            if new_product_types_conf and provider in self.providers_config:
                 try:
                     if hasattr(self.providers_config[provider], "search"):
                         search_plugin_config = self.providers_config[provider].search
@@ -700,6 +700,7 @@ class EODataAccessGateway(object):
                         provider,
                     )
                     continue
+                new_product_types = []
                 for (
                     new_product_type,
                     new_product_type_conf,
@@ -743,10 +744,15 @@ class EODataAccessGateway(object):
                                 self.product_types_config.source
                             )
                             ext_product_types_conf[provider] = new_product_types_conf
-                            logger.debug(
-                                f"Added product type {new_product_type} for {provider}"
-                            )
+                            new_product_types.append(new_product_type)
+                if new_product_types:
+                    logger.debug(
+                        f"Added product types {str(new_product_types)} for {provider}"
+                    )
 
+            elif provider not in self.providers_config:
+                # unknown provider
+                continue
             self.providers_config[provider].product_types_fetched = True
 
         # re-create _plugins_manager using up-to-date providers_config


Test patch:
diff --git a/tests/units/test_core.py b/tests/units/test_core.py
index ec8a5e21..d74b34ce 100644
--- a/tests/units/test_core.py
+++ b/tests/units/test_core.py
@@ -348,6 +348,15 @@ class TestCore(TestCoreBase):
             self.dag.product_types_config["bar"]["title"], "Bar collection"
         )
 
+    def test_update_product_types_list_unknown_provider(self):
+        """Core api.update_product_types_list on unkwnown provider must not crash and not update conf"""
+        with open(os.path.join(TEST_RESOURCES_PATH, "ext_product_types.json")) as f:
+            ext_product_types_conf = json.load(f)
+        self.dag.providers_config.pop("astraea_eod")
+
+        self.dag.update_product_types_list(ext_product_types_conf)
+        self.assertNotIn("astraea_eod", self.dag.providers_config)
+
     @mock.patch(
         "eodag.plugins.search.qssearch.QueryStringSearch.discover_product_types",
         autospec=True,
Repository: CS-SI/eodag
Pull request #484 (2022-07-20 14:39:16)

fix: update provider with new plugin entry
Fixes missing plugin when added through a provider's config update, that did not have a plugin entry of this type configured yet

See test as example (`foo_provider` had no `auth` plugin configured before):
https://github.com/CS-SI/eodag/blob/a973a8d340710bfda2f67194a135ae8dcfe7ac81/tests/integration/test_core_config.py#L97-L110


Patch:
diff --git a/eodag/config.py b/eodag/config.py
index 814c74e9..24e3c499 100644
--- a/eodag/config.py
+++ b/eodag/config.py
@@ -163,8 +163,11 @@ class ProviderConfig(yaml.YAMLObject):
         )
         for key in ("api", "search", "download", "auth"):
             current_value = getattr(self, key, None)
+            mapping_value = mapping.get(key, {})
             if current_value is not None:
-                current_value.update(mapping.get(key, {}))
+                current_value.update(mapping_value)
+            elif mapping_value:
+                setattr(self, key, PluginConfig.from_mapping(mapping_value))
 
 
 class PluginConfig(yaml.YAMLObject):


Test patch:
diff --git a/tests/context.py b/tests/context.py
index 8ed53b99..790d8cdf 100644
--- a/tests/context.py
+++ b/tests/context.py
@@ -38,6 +38,7 @@ from eodag.config import (
     load_stac_provider_config,
     get_ext_product_types_conf,
     EXT_PRODUCT_TYPES_CONF_URI,
+    PluginConfig,
 )
 from eodag.plugins.apis.ecmwf import EcmwfApi
 from eodag.plugins.authentication.base import Authentication
diff --git a/tests/integration/test_core_config.py b/tests/integration/test_core_config.py
index 9109420f..d54c8a22 100644
--- a/tests/integration/test_core_config.py
+++ b/tests/integration/test_core_config.py
@@ -19,7 +19,7 @@
 import tempfile
 from unittest import TestCase, mock
 
-from tests.context import EODataAccessGateway
+from tests.context import EODataAccessGateway, PluginConfig
 
 
 class TestCoreProvidersConfig(TestCase):
@@ -93,3 +93,18 @@ class TestCoreProvidersConfig(TestCase):
         mock__request.return_value.json.side_effect = mock__request_side_effect
         prods, _ = self.dag.search(raise_errors=True)
         self.assertEqual(prods[0].properties["title"], "baz")
+
+        # update provider with new plugin entry
+        self.dag.update_providers_config(
+            """
+            foo_provider:
+                auth:
+                    type: GenericAuth
+            """
+        )
+        self.assertIsInstance(
+            self.dag.providers_config["foo_provider"].auth, PluginConfig
+        )
+        self.assertEqual(
+            self.dag.providers_config["foo_provider"].auth.type, "GenericAuth"
+        )