Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-17720: Drop expression parsing in GraphBuilder #87

Merged
merged 1 commit into from
Feb 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 1 addition & 35 deletions python/lsst/pipe/base/graphBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
# -----------------------------
from .graph import QuantumGraphTaskNodes, QuantumGraph
from lsst.daf.butler import Quantum, DatasetRef
from lsst.daf.butler.exprParser import ParserYacc, ParserYaccError

# ----------------------------------
# Local non-exported definitions --
Expand All @@ -61,15 +60,6 @@ class GraphBuilderError(Exception):
pass


class UserExpressionError(GraphBuilderError):
"""Exception generated by graph builder for error in user expression.
"""

def __init__(self, expr, exc):
msg = "Failed to parse user expression `{}' ({})".format(expr, exc)
GraphBuilderError.__init__(self, msg)


class OutputExistsError(GraphBuilderError):
"""Exception generated when output datasets already exist.
"""
Expand Down Expand Up @@ -107,28 +97,6 @@ def __init__(self, taskFactory, registry, skipExisting=True):
self.dimensions = registry.dimensions
self.skipExisting = skipExisting

@staticmethod
def _parseUserQuery(userQuery):
"""Parse user query.

Parameters
----------
userQuery : `str`
User expression string specifying data selecton.

Returns
-------
`exprTree.Node` instance representing parsed expression tree.
"""
parser = ParserYacc()
# do parsing, this will raise exception
try:
tree = parser.parse(userQuery)
_LOG.debug("parsed expression: %s", tree)
except ParserYaccError as exc:
raise UserExpressionError(userQuery, exc)
return tree

def _loadTaskClass(self, taskDef):
"""Make sure task class is loaded.

Expand Down Expand Up @@ -270,9 +238,7 @@ def _makeGraph(self, taskDatasets, inputs, outputs, initInputs, initOutputs, ori
-------
`QuantumGraph` instance.
"""
parsedQuery = self._parseUserQuery(userQuery or "")
expr = None if parsedQuery is None else str(parsedQuery)
rows = self.registry.selectDimensions(originInfo, expr, inputs, outputs)
rows = self.registry.selectDimensions(originInfo, userQuery, inputs, outputs)

# store result locally for multi-pass algorithm below
# TODO: change it to single pass
Expand Down