Skip to content

Commit 670375b

Browse files
authored
Merge pull request #251 from IFCA-Advanced-Computing/upstream_fix/config_terms
Fix: import ConfigTerms from api/evaluator
2 parents 22cb374 + 189a4ed commit 670375b

File tree

1 file changed

+1
-47
lines changed

1 file changed

+1
-47
lines changed

plugins/digital_csic/plugin.py

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -16,60 +16,14 @@
1616
from bs4 import BeautifulSoup
1717

1818
import api.utils as ut
19-
from api.evaluator import Evaluator
19+
from api.evaluator import ConfigTerms, Evaluator
2020

2121
logging.basicConfig(
2222
stream=sys.stdout, level=logging.DEBUG, format="'%(name)s:%(lineno)s' | %(message)s"
2323
)
2424
logger = logging.getLogger("api.plugin")
2525

2626

27-
class ConfigTerms(property):
28-
def __init__(self, term_id):
29-
self.term_id = term_id
30-
31-
def __call__(self, wrapped_func):
32-
@wraps(wrapped_func)
33-
def wrapper(plugin, **kwargs):
34-
metadata = plugin.metadata
35-
has_metadata = True
36-
37-
term_list = ast.literal_eval(plugin.config[plugin.name][self.term_id])
38-
# Get values in config for the given term
39-
if not term_list:
40-
msg = (
41-
"Cannot find any value for term <%s> in configuration"
42-
% self.term_id
43-
)
44-
has_metadata = False
45-
else:
46-
# Get metadata associated with the term ID
47-
term_metadata = pd.DataFrame(
48-
term_list, columns=["element", "qualifier"]
49-
)
50-
term_metadata = ut.check_metadata_terms_with_values(
51-
metadata, term_metadata
52-
)
53-
if term_metadata.empty:
54-
msg = (
55-
"No access information can be found in the metadata for: %s. Please double-check the value/s provided for '%s' configuration parameter"
56-
% (term_list, self.term_id)
57-
)
58-
has_metadata = False
59-
60-
if not has_metadata:
61-
logger.warning(msg)
62-
return (0, [{"message": msg, "points": 0}])
63-
64-
# Update kwargs with collected metadata for the required terms
65-
kwargs.update(
66-
{self.term_id: {"list": term_list, "metadata": term_metadata}}
67-
)
68-
return wrapped_func(plugin, **kwargs)
69-
70-
return wrapper
71-
72-
7327
class Plugin(Evaluator):
7428
"""A class used to define FAIR indicators tests. It is tailored towards the
7529
DigitalCSIC repository.

0 commit comments

Comments
 (0)