Skip to content

Commit

Permalink
Fetchers s3 and gs were not automatically recognized as valid because…
Browse files Browse the repository at this point in the history
… they still had a non standard SCHEME_HANDLERS
  • Loading branch information
jmfernandez committed Apr 25, 2024
1 parent ce78753 commit 45d6f5b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions wfexs_backend/fetchers/gs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

# SPDX-License-Identifier: Apache-2.0
# Copyright 2020-2023 Barcelona Supercomputing Center (BSC), Spain
# Copyright 2020-2024 Barcelona Supercomputing Center (BSC), Spain
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -147,7 +147,7 @@ def downloadContentFrom_gs(
)


GS_SCHEME_HANDLERS: "Mapping[str, DocumentedProtocolFetcher]" = {
SCHEME_HANDLERS: "Mapping[str, DocumentedProtocolFetcher]" = {
"gs": DocumentedProtocolFetcher(
fetcher=downloadContentFrom_gs,
description="Google Cloud Storage resource path scheme, whose downloads are delegated on Google Cloud Storage libraries",
Expand Down
4 changes: 2 additions & 2 deletions wfexs_backend/fetchers/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

# SPDX-License-Identifier: Apache-2.0
# Copyright 2020-2023 Barcelona Supercomputing Center (BSC), Spain
# Copyright 2020-2024 Barcelona Supercomputing Center (BSC), Spain
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -145,7 +145,7 @@ def downloadContentFrom_s3(
)


S3_SCHEME_HANDLERS: "Mapping[str, DocumentedProtocolFetcher]" = {
SCHEME_HANDLERS: "Mapping[str, DocumentedProtocolFetcher]" = {
"s3": DocumentedProtocolFetcher(
fetcher=downloadContentFrom_s3,
description="Amazon S3 resource path scheme, whose downloads are delegated on libraries implementing its support",
Expand Down
12 changes: 12 additions & 0 deletions wfexs_backend/wfexs_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,10 @@ def findAndAddExportPluginsFromModule(
# Now, let's learn whether the class is enabled
if getattr(obj, "ENABLED", False):
self.addExportPlugin(obj)
else:
self.logger.debug(
f"Export class {name} from module {named_module} was not eligible"
)

def addExportPlugin(self, exportClazz: "Type[AbstractExportPlugin]") -> None:
self._export_plugins[exportClazz.PluginName()] = exportClazz
Expand Down Expand Up @@ -734,13 +738,15 @@ def findAndAddSchemeHandlersFromModule(
# First, try locating a variable named SCHEME_HANDLERS
# then, the different class declarations inheriting
# from AbstractStatefulFetcher
skipit = True
for name, obj in inspect.getmembers(named_module):
if name == "SCHEME_HANDLERS":
if isinstance(obj, dict):
self.addSchemeHandlers(
obj,
fetchers_setup_block=fetchers_setup_block,
)
skipit = False
elif (
inspect.isclass(obj)
and not inspect.isabstract(obj)
Expand All @@ -752,6 +758,12 @@ def findAndAddSchemeHandlersFromModule(
obj,
fetchers_setup_block=fetchers_setup_block,
)
skipit = False

if skipit:
self.logger.debug(
f"Fetch module {named_module} was not eligible (no SCHEME_HANDLERS dictionary or subclass of {AbstractStatefulFetcher.__name__})"
)

def addStatefulSchemeHandlers(
self,
Expand Down

0 comments on commit 45d6f5b

Please sign in to comment.