Exemplo n.º 1
0
def setup_parallel():
    pm = ProgressInsight(Name='MainWorkflow',
                         DbConnection=MockProgressManager())
    a = ProgressTracker(Name='CopyFiles',
                        FriendlyId='a',
                        HasParallelChildren=True)
    b = ProgressTracker(Name='CreateFolder', FriendlyId='b')
    c = ProgressTracker(Name='CopyFiles', FriendlyId='c', EstimatedSeconds=10)
    b1 = ProgressTracker(Name='CreateFolder', FriendlyId='br1')
    c1 = ProgressTracker(Name='CopyFiles',
                         FriendlyId='c1',
                         EstimatedSeconds=11)
    b2 = ProgressTracker(Name='CreateFolder', FriendlyId='b2')
    c2 = ProgressTracker(Name='CopyFiles',
                         FriendlyId='c2',
                         EstimatedSeconds=12)
    d2 = ProgressTracker(Name='CopyFiles',
                         FriendlyId='c2',
                         EstimatedSeconds=12)
    assert a.friendly_id == 'a'
    b.with_tracker(c)
    b1.with_tracker(c1)
    b2.with_tracker(c2)
    c2.with_tracker(d2)
    a.with_tracker(b)
    a.with_tracker(b1)
    a.with_tracker(b2)
    pm.with_tracker(a)
    return pm
Exemplo n.º 2
0
def setup_basic_d():
    pm = ProgressInsight(Name='MainWorkflow', DbConnection=DynamoDbDriver())
    a = ProgressTracker(Name='CopyFiles', FriendlyId='a')
    b = ProgressTracker(Name='CreateFolder', FriendlyId='b')
    c = ProgressTracker(Name='CopyFiles', FriendlyId='c', EstimatedSeconds=10)
    assert a.friendly_id == 'a'
    pm.with_tracker(a)
    a.with_tracker(b)
    b.with_tracker(c)
    return pm
Exemplo n.º 3
0
def test_can_total_progress_with_child_events():
    pm = ProgressInsight(DbConnection=MockProgressManager())
    a = ProgressTracker(Name='CopyFiles', FriendlyId='abc')
    b = ProgressTracker(Name='CreateFolder')
    c = ProgressTracker(Name='CopyFiles')
    d = ProgressTracker(Name='SendEmail')
    a.with_tracker(b)
    b.with_tracker(c).with_tracker(d)
    pm.with_tracker(a)
    assert len(pm.all_children) == 4
Exemplo n.º 4
0
# or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and limitations under the License.
import redis
from progressinsight import RedisProgressManager, ProgressInsight, \
    ProgressTracker
pool = redis.ConnectionPool(host='localhost', port=6379, db=0)
r = redis.Redis(connection_pool=pool)
rroot = RedisProgressManager(RedisConnection=r)
root = ProgressInsight(DbConnection=rroot, Name="MasterWorkflow")
wf_a = ProgressTracker(Name='Workflow A', FriendlyId='WorkflowA')
wf_b = ProgressTracker(Name='Workflow B', FriendlyId='WorkflowB')
wf_b_1 = ProgressTracker(Name='SubWorkflow B1', FriendlyId='WorkflowB1')
wf_b_2 = ProgressTracker(Name='SubWorkflow B2', FriendlyId='WorkflowB2')
task_a1 = ProgressTracker(Name='Task A-1', FriendlyId='TaskA1')
task_a2 = ProgressTracker(Name='Task A-2', FriendlyId='TaskA2')
task_b2_1 = ProgressTracker(Name='Task B2-1', FriendlyId='TaskB21')
root.with_tracker(wf_a).with_tracker(wf_b)
wf_b.with_tracker(wf_b_1).with_tracker(wf_b_2)
wf_a.with_tracker(task_a1).with_tracker(task_a2)
wf_b_2.with_tracker(task_b2_1)
task_b2_1.start(Parents=True)
print "Total items started: {}".format(root.in_progress_count)
print "Percentage started: {}".format(root.in_progress_pct)
root.update_all()
id = root.id
root2 = ProgressInsight(DbConnection=rroot)
print "Total items: {}".format(root2.all_children_count)
root2 = root.load(id)
print "Total items started: {}".format(root2.in_progress_count)
print "Percentage started: {}".format(root2.in_progress_pct)
Exemplo n.º 5
0
import redis
import time
from progressinsight import RedisProgressManager, ProgressInsight, \
    ProgressTracker
pool = redis.ConnectionPool(host='localhost', port=6379, db=0)
r = redis.Redis(connection_pool=pool)
rpm = RedisProgressManager(RedisConnection=r)
pm = ProgressInsight(DbConnection=rpm, Name="MasterWorkflow")
wf_a = ProgressTracker(Name='Workflow A', FriendlyId='WorkflowA')
wf_b = ProgressTracker(Name='Workflow B', FriendlyId='WorkflowB')
wf_b_1 = ProgressTracker(Name='SubWorkflow B1', FriendlyId='WorkflowB1')
wf_b_2 = ProgressTracker(Name='SubWorkflow B2', FriendlyId='WorkflowB2')
task_a1 = ProgressTracker(Name='Task A-1', EstimatedSeconds=10)
task_a2 = ProgressTracker(Name='Task A-2', EstimatedSeconds=10)
task_b2_1 = ProgressTracker(Name='Task B2-1', EstimatedSeconds=10)
task_b2_1_a = ProgressTracker(Name='Task B2-1-a', EstimatedSeconds=10)
pm.with_tracker(wf_a).with_tracker(wf_b)
wf_b.with_tracker(wf_b_1).with_tracker(wf_b_2)
wf_a.with_tracker(task_a1).with_tracker(task_a2)
wf_b_2.with_tracker(task_b2_1)
task_b2_1.with_tracker(task_b2_1_a)
print "Total estimated seconds: {}".format(pm.total_estimate)
task_b2_1.start(Parents=True)
time.sleep(2)
print "Total elapsed time in secs: {}".format(pm.elapsed_time_in_seconds)
print "Total remaining time in secs: {}".format(pm.remaining_time_in_seconds)
print "Workflow B elapsed time: {}".format(wf_b_2.elapsed_time_in_seconds)
print "Workflow B remaining time: {}".format(wf_b_2.remaining_time_in_seconds)

print pm.print_tree()
Exemplo n.º 6
0
import redis
import time
from progressinsight import RedisProgressManager, ProgressInsight, ProgressTracker
pool = redis.ConnectionPool(host='localhost', port=6379, db=0)
r = redis.Redis(connection_pool=pool)
rpm = RedisProgressManager(RedisConnection=r)
pm = ProgressInsight(DbConnection=rpm)
c = ProgressTracker(Name='ConvertVMWorkflow').with_metric(Namespace='test',
                                                          Metric='convert_vm')
c.metric.with_dimension('linux_flavor', 'redhat') \
        .with_dimension('version', '6.8')
pm.with_tracker(c)
pm.update_all()
c.start(Parents=True)
pm.update_all()
print 'sleeping'
time.sleep(2)
c.succeed()
pm.update_all()
print c.elapsed_time_in_seconds
print c.start_time
print c.finish_time
Exemplo n.º 7
0
# Licensed under the Amazon Software License (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at

#    http://aws.amazon.com/asl/

# or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and limitations under the License.
import redis
import time
from progressinsight import RedisProgressManager, ProgressInsight, \
    ProgressTracker
pool = redis.ConnectionPool(host='localhost', port=6379, db=0)
r = redis.Redis(connection_pool=pool)
rpm = RedisProgressManager(RedisConnection=r)
pm = ProgressInsight(DbConnection=rpm, Name="MasterWorkflow")
task = ProgressTracker(Name='SingleTask', FriendlyId='MyTask')
pm.with_tracker(task)
print pm.status, task.status
print pm.start()
print pm.status, task.status
time.sleep(1)
print pm.elapsed_time_in_seconds, task.elapsed_time_in_seconds
task.start()
time.sleep(1)
print pm.status, task.status
print pm.elapsed_time_in_seconds, task.elapsed_time_in_seconds
task.succeed()
pm.succeed()
print pm.status, task.status
print pm.elapsed_time_in_seconds, task.elapsed_time_in_seconds

#    http://aws.amazon.com/asl/

# or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and limitations under the License.
import redis
import time
from progressinsight import RedisProgressManager, ProgressInsight, \
    ProgressTracker
pool = redis.ConnectionPool(host='localhost', port=6379, db=0)
r = redis.Redis(connection_pool=pool)
rpm = RedisProgressManager(RedisConnection=r)
pm = ProgressInsight(DbConnection=rpm, Name="MasterWorkflow")
task_a = ProgressTracker(Name='Task A', FriendlyId='TaskA')
task_b = ProgressTracker(Name='Task B', FriendlyId='TaskB')
task_c = ProgressTracker(Name='Task C', FriendlyId='TaskC')
pm.with_tracker(task_a).with_tracker(task_b).with_tracker(task_c)
print pm.status, task_a.status
print pm.start()
print pm.status, task_a.status, task_b.status, task_c.status
time.sleep(1)
task_a.start()
time.sleep(1)
task_b.start()
time.sleep(1)
task_c.start()
print pm.elapsed_time_in_seconds, \
      task_a.elapsed_time_in_seconds, \
      task_b.elapsed_time_in_seconds, \
      task_c.elapsed_time_in_seconds

task_a.succeed(Message='This task succeeded')
Exemplo n.º 9
0
pm = ProgressInsight(DbConnection=rpm)


def create_children(t, n):
    r = random.randint(0, 10)
    i = 0
    while i < n:
        c = ProgressTracker()
        t.with_tracker(c)
        if r == 0:
            c.start(Parents=True)
        i = i + 1


t = ProgressTracker()
pm.with_tracker(t)
create_children(t, 100)
for c in t.all_children:
    create_children(c, 100)
print t.all_children_count
print t.in_progress_count
print t.in_progress_pct
#print t.print_tree()
print 'updating;'
pm.update_all()
print 'updating again;'
pm.update_all()
print 'loading'
l = pm.load(pm.id)
print 'loaded'
print pm.all_children_count