Skip to content

Commit 14b6ce1

Browse files
authored
SNO-201-add-search-config-registry (#3855)
1 parent 4191cfe commit 14b6ce1

File tree

11 files changed

+94
-1
lines changed

11 files changed

+94
-1
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
README = open(os.path.join(here, 'README.md')).read()
66
CHANGES = open(os.path.join(here, 'CHANGES.rst')).read()
77
# Edit Snovault version after the `@` here, can be a branch or tag
8-
SNOVAULT_DEP = "git+https://github.com/ENCODE-DCC/snovault.git@1.0.56"
8+
SNOVAULT_DEP = "git+https://github.com/ENCODE-DCC/snovault.git@SNO-201-add-search-config-registry"
99

1010
INSTALL_REQUIRES = [
1111
"PasteDeploy==2.1.0",

src/encoded/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ def main(global_config, **local_config):
267267
# registered.
268268
config.include('.upgrade')
269269
config.include('.audit')
270+
config.include('.searches.configs')
270271

271272
app = config.make_wsgi_app()
272273

src/encoded/searches/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

src/encoded/searches/configs.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
from snovault.elasticsearch.searches.interfaces import SEARCH_CONFIG
2+
from snovault.elasticsearch.searches.configs import search_config
3+
4+
5+
def includeme(config):
6+
config.scan(__name__)
7+
config.registry[SEARCH_CONFIG].add_aliases(ALIASES)
8+
config.registry[SEARCH_CONFIG].add_defaults(DEFAULTS)
9+
10+
11+
@search_config(
12+
name='custom'
13+
)
14+
def custom_search_config():
15+
return {
16+
'facets': {
17+
'assay_title': {
18+
'title': 'Assay title',
19+
'type': 'typeahead',
20+
'open_on_load': True
21+
},
22+
'status': {
23+
'title': 'Status',
24+
"open_on_load": True
25+
},
26+
'target.label': {
27+
'title': 'Target of assay',
28+
'type': 'typeahead',
29+
'length': 'long',
30+
'open_on_load': True
31+
},
32+
'biosample_ontology.term_name' : {
33+
'title': 'Biosample term name',
34+
'type': 'typeahead',
35+
'length': 'long',
36+
"open_on_load": True
37+
},
38+
},
39+
'columns': {},
40+
'matrix': {},
41+
'boost_values': {},
42+
'fields': {},
43+
}
44+
45+
46+
ALIASES = {
47+
'DonorSubtypes': [
48+
'HumanDonor',
49+
'FlyDonor',
50+
'WormDonor',
51+
'MouseDonor',
52+
]
53+
}
54+
55+
56+
DEFAULTS = {
57+
'Donor': ['DonorSubtypes'],
58+
('Experiment', 'FunctionalCharacterizationExperiment'): ['Experiment'],
59+
}

src/encoded/searches/defaults.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
'remove',
1717
'sort',
1818
'type',
19+
'config',
1920
]
2021

2122
FREE_TEXT_QUERIES = [

src/encoded/tests/test_auditor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def test_declarative_config(dummy_request):
8787
config = Configurator()
8888
config.include('snovault.config')
8989
config.include('snovault.auditor')
90+
config.include('snovault.elasticsearch.searches.configs')
9091
config.include('.testing_auditor')
9192
config.commit()
9293

src/encoded/types/base.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
AfterModified,
2828
BeforeModified
2929
)
30+
from snovault.elasticsearch.searches.configs import search_config
3031

3132

3233
@lru_cache()
@@ -380,6 +381,23 @@ def set_status(self, new_status, request, parent=True):
380381
return True
381382

382383

384+
@search_config(
385+
name='Item'
386+
)
387+
def item_search_config():
388+
return {
389+
'facets': {
390+
'type': {
391+
'title': 'Data Type',
392+
'exclude': ['Item']
393+
},
394+
'status': {
395+
'title': 'Item status'
396+
},
397+
}
398+
}
399+
400+
383401
class SharedItem(Item):
384402
''' An Item visible to all authenticated users while "in progress".
385403
'''

src/encoded/types/characterization.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
})
3333
class Characterization(ItemWithAttachment, Item):
3434
base_types = ['Characterization'] + Item.base_types
35+
schema = load_schema('encoded:schemas/characterization.json')
3536
embedded = ['lab', 'award', 'submitted_by', 'documents']
3637
set_status_up = [
3738
'documents',

src/encoded/types/dataset.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def calculate_assembly(request, files_list, status):
6969
})
7070
class Dataset(Item):
7171
base_types = ['Dataset'] + Item.base_types
72+
schema = load_schema('encoded:schemas/dataset.json')
7273
embedded = [
7374
'analyses',
7475
'files',
@@ -558,6 +559,14 @@ def superseded_by(self, request, superseded_by):
558559
return paths_filtered_by_status(request, superseded_by)
559560

560561

562+
@abstract_collection(
563+
name='file-set',
564+
unique_key='accession',
565+
properties={
566+
'title': "File set",
567+
'description': 'A set of files.',
568+
}
569+
)
561570
class FileSet(Dataset):
562571
item_type = 'file_set'
563572
base_types = ['FileSet'] + Dataset.base_types

src/encoded/types/donor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
})
2222
class Donor(Item):
2323
base_types = ['Donor'] + Item.base_types
24+
schema = load_schema('encoded:schemas/donor.json')
2425
embedded = [
2526
'organism',
2627
'characterizations',

0 commit comments

Comments
 (0)