Skip to content

Commit

Permalink
Adding utility function to get to models.Variable
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Jun 16, 2015
1 parent cc44e4d commit 9c36068
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions airflow/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import getpass
import imp
import jinja2
import json
import logging
import os
import dill
Expand Down Expand Up @@ -1784,6 +1785,15 @@ class Variable(Base):
def __repr__(self):
return '{} : {}'.format(self.key, self.val)

@classmethod
@provide_session
def get(cls, key, session, deserialize_json=False):
obj = session.query(cls).filter(cls.key == key).first()
v = obj.val
if deserialize_json and v:
v = json.loads(v)
return v


class Pool(Base):
__tablename__ = "slot_pool"
Expand Down

0 comments on commit 9c36068

Please sign in to comment.