From 153b5a460fb6d33192305268e6097d73aa76b9cc Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Mon, 13 May 2013 14:11:51 -0700 Subject: [PATCH] Remove the promise object for now --- taskflow/job.py | 7 ++++++- taskflow/logbook.py | 4 +++- taskflow/promise.py | 49 --------------------------------------------- 3 files changed, 9 insertions(+), 51 deletions(-) delete mode 100644 taskflow/promise.py diff --git a/taskflow/job.py b/taskflow/job.py index ed1d4c1f..a8a0219c 100644 --- a/taskflow/job.py +++ b/taskflow/job.py @@ -23,7 +23,7 @@ from taskflow import exceptions as exc from taskflow import states -class JobClaimer(object): +class Claimer(object): """A base class for objects that can attempt to claim a given claim a given job, so that said job can be worked on.""" @@ -57,6 +57,7 @@ class Job(object): @property def logbook(self): + """Fetches (or creates) a logbook entry for this job.""" if self._logbook is None: if self in self._catalog: self._logbook = self._catalog.fetch(self) @@ -83,6 +84,10 @@ class Job(object): self.state = new_state # TODO(harlowja): update the logbook + def await(self, blocking=True, timeout=None): + """Attempts to wait until the job fails or finishes.""" + raise NotImplementedError() + def erase(self): """Erases any traces of this job from its associated resources.""" for b in self.posted_on: diff --git a/taskflow/logbook.py b/taskflow/logbook.py index e74ca40c..6fee45fe 100644 --- a/taskflow/logbook.py +++ b/taskflow/logbook.py @@ -21,7 +21,9 @@ import abc from datetime import datetime -class LogEntry(object): +class Entry(object): + """A logbook entry has the bare minimum of these fields.""" + def __init__(self, name, metadata=None): self.created_on = datetime.utcnow() self.name = name diff --git a/taskflow/promise.py b/taskflow/promise.py deleted file mode 100644 index dfce9c75..00000000 --- a/taskflow/promise.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- - -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# Copyright (C) 2012 Yahoo! Inc. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import abc - - -class Promise(object): - """This is an abstraction of a promise to perform some type of job which - can be returned to a user/function... for later lookup on the progress of - the underlying job.""" - - __metaclass__ = abc.ABCMeta - - def __init__(self, job): - self._job = job - - @property - def tracking_id(self): - return "p-%s" % (self._job.tracking_id) - - def await(self, timeout=None): - """Attempts to wait until the job fails or finishess.""" - raise NotImplementedError() - - @abc.abstractproperty - def state(self): - """Returns the state of the underlying job.""" - raise NotImplementedError() - - @abc.abstractproperty - def owner(self): - """Returns the owner of the job, or None if no owner - has been assigned.""" - raise NotImplementedError()