Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
PEDASI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Research Software Group
PEDASI
Commits
94454b4b
Commit
94454b4b
authored
6 years ago
by
James Graham
Browse files
Options
Downloads
Patches
Plain Diff
Fix failing API tests - search framework required connector plugin set
parent
bd3cbc4c
No related branches found
No related tags found
1 merge request
!60
Merge dev pre-hackday
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
datasources/models.py
+21
-5
21 additions, 5 deletions
datasources/models.py
with
21 additions
and
5 deletions
datasources/models.py
+
21
−
5
View file @
94454b4b
import
json
import
typing
from
django.conf
import
settings
from
django.contrib.auth.models
import
Group
...
...
@@ -42,11 +43,24 @@ class DataSource(BaseAppDataModel):
self
.
_data_connector
=
None
@property
def
data_connector
(
self
):
def
data_connector
(
self
)
->
BaseDataConnector
:
"""
Construct the data connector for this source.
:return: Data connector instance
"""
if
self
.
_data_connector
is
None
:
BaseDataConnector
.
load_plugins
(
'
datasources/connectors
'
)
try
:
plugin
=
BaseDataConnector
.
get_plugin
(
self
.
plugin_name
)
except
KeyError
as
e
:
if
not
self
.
plugin_name
:
raise
ValueError
(
'
Data source plugin is not set
'
)
from
e
raise
KeyError
(
'
Data source plugin not found
'
)
from
e
if
self
.
api_key
:
self
.
_data_connector
=
plugin
(
self
.
url
,
self
.
api_key
)
else
:
...
...
@@ -55,7 +69,7 @@ class DataSource(BaseAppDataModel):
return
self
.
_data_connector
@property
def
search_representation
(
self
):
def
search_representation
(
self
)
->
typing
.
List
[
str
]
:
lines
=
[]
lines
.
append
(
self
.
name
)
...
...
@@ -67,11 +81,13 @@ class DataSource(BaseAppDataModel):
self
.
data_connector
.
get_metadata
(),
indent
=
4
))
except
NotImplementedError
:
except
(
KeyError
,
NotImplementedError
,
ValueError
):
# KeyError: Plugin was not found
# NotImplementedError: Plugin does not support metadata
# ValueError: Plugin was not set
pass
result
=
'
\n
'
.
join
(
lines
)
print
(
result
)
return
result
def
get_absolute_url
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment