@@ -89,7 +89,7 @@ def __init__(self,
89
89
name , uri , uri_type , filename = 'usage_scenario.yml' , branch = None ,
90
90
debug_mode = False , allow_unsafe = False , no_file_cleanup = False , skip_system_checks = False ,
91
91
skip_unsafe = False , verbose_provider_boot = False , full_docker_prune = False ,
92
- dry_run = False , dev_repeat_run = False , docker_prune = False , job_id = None ):
92
+ dev_no_sleeps = False , dev_no_build = False , dev_no_metrics = False , docker_prune = False , job_id = None ):
93
93
94
94
if skip_unsafe is True and allow_unsafe is True :
95
95
raise RuntimeError ('Cannot specify both --skip-unsafe and --allow-unsafe' )
@@ -104,8 +104,9 @@ def __init__(self,
104
104
self ._verbose_provider_boot = verbose_provider_boot
105
105
self ._full_docker_prune = full_docker_prune
106
106
self ._docker_prune = docker_prune
107
- self ._dry_run = dry_run
108
- self ._dev_repeat_run = dev_repeat_run
107
+ self ._dev_no_sleeps = dev_no_sleeps
108
+ self ._dev_no_build = dev_no_build
109
+ self ._dev_no_metrics = dev_no_metrics
109
110
self ._uri = uri
110
111
self ._uri_type = uri_type
111
112
self ._original_filename = filename
@@ -145,7 +146,7 @@ def __init__(self,
145
146
# self.__filename = self._original_filename # this can be changed later if working directory changes
146
147
147
148
def custom_sleep (self , sleep_time ):
148
- if not self ._dry_run :
149
+ if not self ._dev_no_sleeps :
149
150
print (TerminalColors .HEADER , '\n Sleeping for : ' , sleep_time , TerminalColors .ENDC )
150
151
time .sleep (sleep_time )
151
152
@@ -387,13 +388,13 @@ def check_running_containers(self):
387
388
def populate_image_names (self ):
388
389
for service_name , service in self ._usage_scenario .get ('services' , []).items ():
389
390
if not service .get ('image' , None ): # image is a non-mandatory field. But we need it, so we tmp it
390
- if self ._dev_repeat_run :
391
+ if self ._dev_no_build :
391
392
service ['image' ] = f"{ service_name } "
392
393
else :
393
394
service ['image' ] = f"{ service_name } _{ random .randint (500000 ,10000000 )} "
394
395
395
396
def remove_docker_images (self ):
396
- if self ._dev_repeat_run :
397
+ if self ._dev_no_build :
397
398
return
398
399
399
400
print (TerminalColors .HEADER , '\n Removing all temporary GMT images' , TerminalColors .ENDC )
@@ -477,6 +478,10 @@ def update_and_insert_specs(self):
477
478
)
478
479
479
480
def import_metric_providers (self ):
481
+ if self ._dev_no_metrics :
482
+ print (TerminalColors .HEADER , '\n Skipping import of metric providers' , TerminalColors .ENDC )
483
+ return
484
+
480
485
config = GlobalConfig ().config
481
486
482
487
print (TerminalColors .HEADER , '\n Importing metric providers' , TerminalColors .ENDC )
@@ -517,6 +522,10 @@ def import_metric_providers(self):
517
522
self .__metric_providers .sort (key = lambda item : 'rapl' not in item .__class__ .__name__ .lower ())
518
523
519
524
def download_dependencies (self ):
525
+ if self ._dev_no_build :
526
+ print (TerminalColors .HEADER , '\n Skipping downloading dependencies' , TerminalColors .ENDC )
527
+ return
528
+
520
529
print (TerminalColors .HEADER , '\n Downloading dependencies' , TerminalColors .ENDC )
521
530
subprocess .run (['docker' , 'pull' , 'gcr.io/kaniko-project/executor:latest' ], check = True )
522
531
@@ -564,6 +573,7 @@ def build_docker_images(self):
564
573
encoding = 'UTF-8' ,
565
574
check = True )
566
575
# The image exists so exit and don't build
576
+ print (f"Image { service ['image' ]} exists in build cache. Skipping build ..." )
567
577
continue
568
578
except subprocess .CalledProcessError :
569
579
pass
@@ -940,6 +950,9 @@ def add_to_log(self, container_name, message, cmd=''):
940
950
941
951
942
952
def start_metric_providers (self , allow_container = True , allow_other = True ):
953
+ if self ._dev_no_metrics :
954
+ return
955
+
943
956
print (TerminalColors .HEADER , '\n Starting metric providers' , TerminalColors .ENDC )
944
957
945
958
for metric_provider in self .__metric_providers :
@@ -1092,6 +1105,9 @@ def run_flows(self):
1092
1105
1093
1106
# this function should never be called twice to avoid double logging of metrics
1094
1107
def stop_metric_providers (self ):
1108
+ if self ._dev_no_metrics :
1109
+ return
1110
+
1095
1111
print (TerminalColors .HEADER , 'Stopping metric providers and parsing measurements' , TerminalColors .ENDC )
1096
1112
errors = []
1097
1113
for metric_provider in self .__metric_providers :
@@ -1419,8 +1435,9 @@ def run(self):
1419
1435
parser .add_argument ('--verbose-provider-boot' , action = 'store_true' , help = 'Boot metric providers gradually' )
1420
1436
parser .add_argument ('--full-docker-prune' , action = 'store_true' , help = 'Stop and remove all containers, build caches, volumes and images on the system' )
1421
1437
parser .add_argument ('--docker-prune' , action = 'store_true' , help = 'Prune all unassociated build caches, networks volumes and stopped containers on the system' )
1422
- parser .add_argument ('--dry-run' , action = 'store_true' , help = 'Removes all sleeps. Resulting measurement data will be skewed.' )
1423
- parser .add_argument ('--dev-repeat-run' , action = 'store_true' , help = 'Checks if a docker image is already in the local cache and will then not build it. Also doesn\' t clear the images after a run' )
1438
+ parser .add_argument ('--dev-no-metrics' , action = 'store_true' , help = 'Skips loading the metric providers. Runs will be faster, but you will have no metric' )
1439
+ parser .add_argument ('--dev-no-sleeps' , action = 'store_true' , help = 'Removes all sleeps. Resulting measurement data will be skewed.' )
1440
+ parser .add_argument ('--dev-no-build' , action = 'store_true' , help = 'Checks if a container images are already in the local cache and will then not build it. Also doesn\' t clear the images after a run. Please note that skipping builds only works the second time you make a run.' )
1424
1441
parser .add_argument ('--print-logs' , action = 'store_true' , help = 'Prints the container and process logs to stdout' )
1425
1442
1426
1443
args = parser .parse_args ()
@@ -1435,9 +1452,9 @@ def run(self):
1435
1452
error_helpers .log_error ('--allow-unsafe and skip--unsafe in conjuction is not possible' )
1436
1453
sys .exit (1 )
1437
1454
1438
- if args .dev_repeat_run and (args .docker_prune or args .full_docker_prune ):
1455
+ if args .dev_no_build and (args .docker_prune or args .full_docker_prune ):
1439
1456
parser .print_help ()
1440
- error_helpers .log_error ('--dev-repeat-run blocks pruning docker images. Combination is not allowed' )
1457
+ error_helpers .log_error ('--dev-no-build blocks pruning docker images. Combination is not allowed' )
1441
1458
sys .exit (1 )
1442
1459
1443
1460
if args .full_docker_prune and GlobalConfig ().config ['postgresql' ]['host' ] == 'green-coding-postgres-container' :
@@ -1480,8 +1497,8 @@ def run(self):
1480
1497
branch = args .branch , debug_mode = args .debug , allow_unsafe = args .allow_unsafe ,
1481
1498
no_file_cleanup = args .no_file_cleanup , skip_system_checks = args .skip_system_checks ,
1482
1499
skip_unsafe = args .skip_unsafe ,verbose_provider_boot = args .verbose_provider_boot ,
1483
- full_docker_prune = args .full_docker_prune , dry_run = args .dry_run ,
1484
- dev_repeat_run = args .dev_repeat_run , docker_prune = args .docker_prune )
1500
+ full_docker_prune = args .full_docker_prune , dev_no_sleeps = args .dev_no_sleeps ,
1501
+ dev_no_build = args .dev_no_build , dev_no_metrics = args . dev_no_metrics , docker_prune = args .docker_prune )
1485
1502
1486
1503
# Using a very broad exception makes sense in this case as we have excepted all the specific ones before
1487
1504
#pylint: disable=broad-except
0 commit comments