Skip to content

Commit 189a4ed

Browse files
committed
Fix: import ConfigTerms from api/evaluator
1 parent 716964e commit 189a4ed

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,7 +16,7 @@
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"
@@ -25,52 +25,6 @@
2525
logger = logging.getLogger(os.path.basename(__file__))
2626

2727

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

0 commit comments

Comments
 (0)