class A:
    a_id = Column(Integer, primary_key=True)
a_remote = Column(UnicodeText)
latest_a = select([func.max(A.a_id).label('a_id'), A.a_remote]).group_by(A.
    a_remote).alias('latest_a')


class B:
    b_id = Column(Integer, primary_key=True)
foreign_to_a = Column(UnicodeText)
Correlating a SQLAlchemy relationship with an awkward join