conrad-blucher-institute / semaphore

Creative Commons Zero v1.0 Universal
1 stars 0 forks source link

Optimize CRON File and Logging #294

Closed lovelysandlonelys closed 3 months ago

lovelysandlonelys commented 4 months ago

Two distinct tasks

  1. Rather than having so many subfolders have a logs directory, each log has it's own directory, and then there are log files with the date inside of that model file rather than having so many nested folders.
    • logs
      • mlp model
        • mlm-model-yymmdd
  2. Automate the creation of the cron file by reading the timing information from the dspec
    • have an enabled boolean inside of the dspec to make sure that we can show what models we want to be running to the script that builds the cron file

NOTE: the CRON logs are just logging only the standard error not the cron log errors so they are kinda useless

NOTE: the offset value for each inundation model should be offset by some seconds so that all the models are not all running at the same time and utilizing 80% of the CPU

matdenkas commented 3 months ago
lead_times = [12, 24, 48]
for lead_time in lead_times:

    FOLDER_STRUCTURE = f'Magnolia/{lead_time}'

    min = 20
    file_path = f'Magnolia/{lead_time}/magnolia_{lead_time}'
    model = f'{min} * * * * mkdir -p ./logs/$(date "+\%Y")/$(date "+\%m")/{FOLDER_STRUCTURE} && docker exec semaphore-core python3 src/semaphoreRunner.py -d ./{file_path}.json >> ./logs/$(date "+\%Y")/$(date "+\%m")/{file_path}.log'

    min = 25
    file_path = f'Magnolia/{lead_time}/magnolia_transform_{lead_time}'
    transform = f'{min} * * * * mkdir -p ./logs/$(date "+\%Y")/$(date "+\%m")/{FOLDER_STRUCTURE} && docker exec semaphore-core python3 src/semaphoreRunner.py -d ./{file_path}.json >> ./logs/$(date "+\%Y")/$(date "+\%m")/{file_path}.log'

    print(model)
    print(transform)
lovelysandlonelys commented 3 months ago
lovelysandlonelys commented 3 months ago

Meeting Notes:

lovelysandlonelys commented 3 months ago

If the interval is minutely:

matdenkas commented 3 months ago

print(format_timing(300, 3600)) # Hourly run with offset of 10 min
print(format_timing(0, 360)) # No offset run every six min print(format_timing(1200, 10800)) # 20 min offset run every 3 hours print(format_timing(0, 3600)) # No offset run hourly print(format_timing(60, 360)) # No offset run every six min

5 /1 0-59/6 20 /3 0 /1 1-59/6