Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
8e050e5
wip
millerjs Oct 17, 2016
4257f24
wip
millerjs Oct 18, 2016
e28f74a
wip
millerjs Oct 18, 2016
9a520a1
test_graph_active_builder passing barring annotations
millerjs Oct 18, 2016
7746661
test_graph_active_builder passing barring annotations
millerjs Oct 18, 2016
d25df89
wip
millerjs Oct 18, 2016
1c718ac
active: all but annotations passing
millerjs Oct 18, 2016
47e34d6
active: all but annotations passing
millerjs Oct 18, 2016
a12d869
with lru_cached annotation docs
millerjs Oct 18, 2016
427526f
test_graph_legacy_builder passing
millerjs Oct 18, 2016
abb23ed
test_graph_legacy_builder passing
millerjs Oct 18, 2016
2fad00a
wip to fix gdc_elasticsearch regressions
millerjs Oct 18, 2016
4c994b2
wip: nodes are being copied across the queue and aren't in the graph
millerjs Oct 18, 2016
2aa9992
wip: nodes are being copied across the queue and aren't in the graph
millerjs Oct 18, 2016
fc9637c
wip: test_graph_active works in parallel? no manager yet though
millerjs Oct 18, 2016
6c3bc40
wip: manager is instantiated
millerjs Oct 18, 2016
1cc5407
wip: manager is instantiated
millerjs Oct 18, 2016
5a60427
🎉 🎉 🎉 🎉 we've achieved serializability 🎉 🎉 🎉 🎉
millerjs Oct 18, 2016
7f55cb1
wip
millerjs Oct 19, 2016
e2ab1d8
wip add fake node
millerjs Oct 19, 2016
e49d47d
wip optimize loading
millerjs Oct 19, 2016
81772c3
wip
millerjs Oct 19, 2016
18168e1
possibly serialization equivalence issues?
millerjs Oct 19, 2016
a515c29
wip
millerjs Oct 20, 2016
365ab0d
memory graph index works
millerjs Oct 20, 2016
dcb266f
DiskGraphIndex works
millerjs Oct 20, 2016
58bf825
wip
millerjs Oct 20, 2016
9e4c4b3
wip
millerjs Oct 20, 2016
4e83504
add esbuild.graph.common.index
millerjs Oct 20, 2016
a50809d
wip
millerjs Oct 20, 2016
4d33ec1
wip
millerjs Oct 21, 2016
e5c36ae
wip
millerjs Oct 21, 2016
764c3b3
wip
millerjs Oct 21, 2016
4694ba9
wip
millerjs Oct 24, 2016
621afa3
wip
millerjs Nov 18, 2016
7d8a711
wip
millerjs Dec 12, 2016
816300a
wip
millerjs Dec 13, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions esbuild/gdc_elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from gdcdatamodel.models import File
from progressbar import ProgressBar, Percentage, Bar, ETA
from psqlgraph import PsqlGraphDriver
from esbuild.graph.common.cache import CachedGraph

# TODO this could probably be bumped now that the number of bulk
# threads in the config is higher, c.f.
Expand All @@ -44,6 +45,7 @@ def shouldnt_delete(node):
delete them.

"""

if isinstance(node, File) and node.derived_files:
return True
else:
Expand All @@ -55,8 +57,7 @@ class GDCElasticsearch(object):
"""
"""

def __init__(self, converter_class, es=None,
index_base="gdc_from_graph"):
def __init__(self, converter_class, es=None, index_base="gdc_from_graph"):
"""Walks the graph to produce elasticsearch json documents.

:param es: An instance of Elasticsearch class
Expand All @@ -75,22 +76,28 @@ def __init__(self, converter_class, es=None,
os.environ.get("ES_PASSWORD", "")),
timeout=9999)

self.graph = PsqlGraphDriver(
self.psqlgraph_args = (
os.environ["PG_HOST"],
os.environ["PG_USER"],
os.environ["PG_PASS"],
os.environ["PG_NAME"],
)

self.converter = converter_class(self.graph)
self.graph = PsqlGraphDriver(self.psqlgraph_args)

caching_options = converter_class.get_caching_options()
cache = CachedGraph(self.graph, caching_options)
converter = converter_class(cache)

self.converter = converter

def go(self, roll_alias=True):
self.log.info("Caching database")
# having a transation out here is important, since it ensures
# that the cached database and which nodes get deleted is
# consistent
with self.graph.session_scope() as session:
self.converter.cache_database()
self.converter.cache.cache_database()
self.log.info("Querying for old nodes to delete")
to_delete = self.graph.nodes().sysan({"to_delete": True}).all()
to_delete = [n for n in to_delete if not shouldnt_delete(n)]
Expand Down
20 changes: 12 additions & 8 deletions esbuild/graph/active/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def get_parent_with_category(self, node, category):
if l['dst_type']._dictionary['category'] == category
]

return self.neighbors_labeled(node, labels)
return self.cache.neighbors_labeled(node.node_id, labels)

def get_child_with_category(self, node, category):
"""returns iterable of neighors from inbound edges with category"""
Expand All @@ -224,7 +224,7 @@ def get_child_with_category(self, node, category):
if l['src_type']._dictionary['category'] == category
]

return self.neighbors_labeled(node, labels)
return self.cache.neighbors_labeled(node.node_id, labels)

def add_file_analysis(self, node, doc):
"""Add the 'analysis' that produced the current file"""
Expand Down Expand Up @@ -315,7 +315,8 @@ def get_read_group_qc_docs(self, read_group):
"""Returns a list of documents for Read Group QCs"""

read_group_qc_docs = []
rg_qcs = self.neighbors_labeled(read_group, 'read_group_qc')
rg_qcs = self.cache.neighbors_labeled(
read_group.node_id, 'read_group_qc')
for read_group_qc in rg_qcs:
read_group_qc_docs.append(self._get_base_doc(read_group_qc))

Expand All @@ -329,7 +330,7 @@ def get_file_read_groups(self, node):
"""

paths = self.file_to_read_group_paths.get(node.label, [])
return set(self.walk_paths(node, paths))
return set(self.cache.walk_paths(node.node_id, paths))

def get_analysis_read_groups(self, node):
"""Given a analysis node, traverse up the tree to read_groups:
Expand All @@ -356,7 +357,7 @@ def get_simple_file_doc(self, node):

doc['data_format'] = self.get_data_format(node)

for dst in self.neighbors_labeled(node, 'data_subtype'):
for dst in self.cache.neighbors_labeled(node.node_id, 'data_subtype'):
doc['data_type'] = dst['name']

return doc
Expand All @@ -372,15 +373,17 @@ def get_file_associated_entities(self, node):
entity
for rg in self.get_file_read_groups(node)
for entity in
self.neighbors_labeled(rg, self.possible_associated_entites)
self.cache.neighbors_labeled(
rg.node_id, self.possible_associated_entites)
]

# Add entities with one step through a data_file
entities += [
entity
for parent in self.get_parent_with_category(node, 'data_file')
for entity in
self.neighbors_labeled(parent, self.possible_associated_entites)
self.cache.neighbors_labeled(
parent.node_id, self.possible_associated_entites)
]

# Copy number paths
Expand All @@ -389,7 +392,8 @@ def get_file_associated_entities(self, node):
list_product([['aliquot']], self.aliquot_to_copy_number_paths)
]
entities += [
entity for entity in self.walk_paths(node, cnv_paths)
entity for entity in self.cache.walk_paths(
node.node_id, cnv_paths)
]

return list(set(entities))
Loading