def test_can_total_progress_with_child_events(): pm = ProgressMonitor(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
def setup_basic(): pm = ProgressMonitor(Name='MainWorkflow', DbConnection=MockProgressManager()) 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
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. # 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 from progressmonitor import RedisProgressManager, ProgressMonitor, \ ProgressTracker pool = redis.ConnectionPool(host='localhost', port=6379, db=0) r = redis.Redis(connection_pool=pool) rpm = RedisProgressManager(RedisConnection=r) pm = ProgressMonitor(DbConnection=rpm, Name="MasterWorkflow") wf_a = ProgressTracker(Name='Workflow A', FriendlyId='WorkflowA', HasParallelChildren=True) 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) wf_a_1 = ProgressTracker(Name='SubWorkflow A1', HasParallelChildren=True) wf_a1_1 = ProgressTracker(Name='SubWorkflow A1, Task 1', EstimatedSeconds=20) wf_a1_2 = ProgressTracker(Name='SubWorkflow A1, Task 2', EstimatedSeconds=30) pm.with_tracker(wf_a).with_tracker(wf_b) wf_b.with_tracker(wf_b_1).with_tracker(wf_b_2) wf_a_1.with_tracker(wf_a1_1).with_tracker(wf_a1_2) wf_a.with_tracker(task_a1).with_tracker(wf_a_1) print "Total estimated seconds: {}".format(pm.total_estimate)
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. # 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 progressmonitor import RedisProgressManager, ProgressMonitor, \ ProgressTracker pool = redis.ConnectionPool(host='localhost', port=6379, db=0) r = redis.Redis(connection_pool=pool) rpm = RedisProgressManager(RedisConnection=r) pm = ProgressMonitor(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, \
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. # 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 from progressmonitor import RedisProgressManager, ProgressMonitor, \ ProgressTracker pool = redis.ConnectionPool(host='localhost', port=6379, db=0) r = redis.Redis(connection_pool=pool) rroot = RedisProgressManager(RedisConnection=r) root = ProgressMonitor(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) print "Total items in workflow: {}".format(root.all_children_count) print "Total items not started: {}".format(root.not_started_count) print task_b2_1.status, wf_b_2.status, wf_b.status, root.status task_b2_1.start(Parents=True) print "Total items started: {}".format(root.in_progress_count) print "Percentage started: {}".format(root.in_progress_pct)
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. # 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 progressmonitor import RedisProgressManager, ProgressMonitor, \ ProgressTracker pool = redis.ConnectionPool(host='localhost', port=6379, db=0) r = redis.Redis(connection_pool=pool) rpm = RedisProgressManager(RedisConnection=r) pm = ProgressMonitor(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
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. # 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 progressmonitor import RedisProgressManager, ProgressMonitor, \ ProgressTracker pool = redis.ConnectionPool(host='localhost', port=6379, db=0) r = redis.Redis(connection_pool=pool) rpm = RedisProgressManager(RedisConnection=r) pm = ProgressMonitor(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)
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. # 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 progressmonitor import RedisProgressManager, ProgressMonitor, ProgressTracker pool = redis.ConnectionPool(host='localhost', port=6379, db=0) r = redis.Redis(connection_pool=pool) rpm = RedisProgressManager(RedisConnection=r) pm = ProgressMonitor(DbConnection=rpm) c = ProgressTracker(Name='TestWorkflow').with_metric(Namespace='dev_testing', Metric='OS/Startup') 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
def setup_parallel(): pm = ProgressMonitor(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
def test_can_create_rollup_event(): r = ProgressTracker(Id='test') assert r.id == 'test'