-
Notifications
You must be signed in to change notification settings - Fork 850
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2409 from chaoss/add-config-options
Add config options for memory usage and frequency of refresh materialized views
- Loading branch information
Showing
4 changed files
with
74 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
augur/application/schema/alembic/versions/19_add_extra_celery_options_to_the_config_.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
"""Add extra celery options to the config if they do not exist | ||
Revision ID: 19 | ||
Revises: 18 | ||
Create Date: 2023-05-15 12:03:57.171011 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from augur.application.db.session import DatabaseSession | ||
from augur.application.config import * | ||
from sqlalchemy.sql import text | ||
import logging | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '19' | ||
down_revision = '18' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
def upgrade(): | ||
|
||
with DatabaseSession(logger) as session: | ||
config = AugurConfig(logger,session) | ||
config_dict = config.load_config() | ||
|
||
#Update the missing fields of the celery section in the config | ||
section = config_dict.get("Celery") | ||
|
||
#Just copy the default if section doesn't exist. | ||
if section: | ||
if 'worker_process_vmem_cap' not in section.keys(): | ||
section['worker_process_vmem_cap'] = 0.25 | ||
|
||
if 'refresh_materialized_views_interval_in_days' not in section.keys(): | ||
section['refresh_materialized_views_interval_in_days'] = 7 | ||
else: | ||
section = config.default_config["Celery"] | ||
|
||
config.add_section_from_json("Celery", section) | ||
|
||
#delete old setting | ||
session.execute_sql(text(f""" | ||
DELETE FROM augur_operations.config | ||
WHERE section_name='Celery' AND setting_name='concurrency'; | ||
""")) | ||
|
||
|
||
|
||
def downgrade(): | ||
|
||
conn = op.get_bind() | ||
|
||
conn.execute(text(f""" | ||
DELETE FROM augur_operations.config | ||
WHERE section_name='Celery' AND (setting_name='worker_process_vmem_cap' OR setting_name='refresh_materialized_views_interval_in_days'); | ||
""")) | ||
|
||
try: | ||
conn.execute(text(f""" | ||
INSERT INTO augur_operations.config (section_name,setting_name,value,type) VALUES ('Celery','concurrency',12,'int'); | ||
""")) | ||
except: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters