Unverified Commit 986e8292 authored by jlaura's avatar jlaura Committed by GitHub
Browse files

Session cleanup (#473)

* Session cleanup

* Removes extra prints
parent 829c5fe5
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -679,6 +679,9 @@ def subpixel_register_measure(measureid,
    result = {'measureid':measureid,
              'status':''}
    
    if not ncg.Session:
        raise BrokenPipeError('This func requires a database session from a NetworkCandidateGraph.')

    with ncg.session_scope() as session:
        # Setup the measure that is going to be matched
        destination = session.query(Measures).filter(Measures.id == measureid).one()
@@ -757,10 +760,6 @@ def subpixel_register_point(pointid,

    Parameters
    ----------
    ncg : obj
          the network candidate graph that the point is associated with; used for
          the DB session that is able to access the point.

    pointid : int or obj
              The identifier of the point in the DB or a Points object

@@ -779,9 +778,12 @@ def subpixel_register_point(pointid,
    threshold : numeric
                measures with a cost <= the threshold are marked as ignore=True in
                the database.
    ncg : obj
          the network candidate graph that the point is associated with; used for
          the DB session that is able to access the point.
    """
    Session = ncg.Session
    if not Session:

    if not ncg.Session:
        raise BrokenPipeError('This func requires a database session from a NetworkCandidateGraph.')

    if isinstance(pointid, Points):
+2 −4
Original line number Diff line number Diff line
@@ -66,8 +66,7 @@ def place_points_in_overlaps(size_threshold=0.0007,
    size_threshold : float
                     overlaps with area <= this threshold are ignored
    """
    Session = ncg.Session
    if not Session:
    if not ncg.Session:
        raise BrokenPipeError('This func requires a database session from a NetworkCandidateGraph.')

    for overlap in Overlay.overlapping_larger_than(size_threshold, Session):
@@ -110,8 +109,7 @@ def place_points_in_overlap(overlap,
    points : list of Points
        The list of points seeded in the overlap
    """
    Session = ncg.Session
    if not Session:
    if not ncg.Session:
        raise BrokenPipeError('This func requires a database session from a NetworkCandidateGraph.')

    # Determine what sensor type to use
+3 −4
Original line number Diff line number Diff line
@@ -43,11 +43,10 @@ def _instantiate_row(msg, ncg):
    # Get the dict mapping iterable keyword types to the objects
    objdict = ncg.apply_iterable_options
    rowid = msg['id']

    session = ncg.Session()
    obj = objdict[msg['along']]
    with ncg.session_scope() as session:
        res = session.query(obj).filter(getattr(obj, 'id')==msg['id']).one()
    session.close()
        session.expunge(res) # Disconnect the object from the session
    return res

def main(msg):