From cb64a2a0a14266dfa7dda5fa6ff9664977495302 Mon Sep 17 00:00:00 2001 From: "vysakh.menon" Date: Tue, 6 Aug 2024 16:05:30 -0700 Subject: [PATCH] no message --- .../future-effective-filings/file_future_effective.py | 4 ++-- jobs/future-effective-filings/setup.cfg | 1 - jobs/update-colin-filings/update_colin_filings.py | 7 ++++--- jobs/update-legal-filings/update_legal_filings.py | 11 +++++------ 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/jobs/future-effective-filings/file_future_effective.py b/jobs/future-effective-filings/file_future_effective.py index 7a8d044edc..076e5b784e 100644 --- a/jobs/future-effective-filings/file_future_effective.py +++ b/jobs/future-effective-filings/file_future_effective.py @@ -89,7 +89,7 @@ def get_bearer_token(app: Flask, timeout): try: return res.json().get('access_token') - except Exception: + except Exception: # pylint: disable=broad-exception-caught; return None @@ -105,7 +105,7 @@ def get_filing_ids(app: Flask): if not response or response.status_code != 200: app.logger.error(f'Failed to collect filings from legal-api. \ {response} {response.json()} {response.status_code}') - raise Exception + raise Exception # pylint: disable=broad-exception-raised; return response.json() diff --git a/jobs/future-effective-filings/setup.cfg b/jobs/future-effective-filings/setup.cfg index 04dbd10354..e9ff19f993 100644 --- a/jobs/future-effective-filings/setup.cfg +++ b/jobs/future-effective-filings/setup.cfg @@ -70,7 +70,6 @@ good-names= [pylint] ignore=migrations,test -max_line_length=120 notes=FIXME,XXX,TODO ignored-modules=flask_sqlalchemy,sqlalchemy,SQLAlchemy,alembic,scoped_session ignored-classes=scoped_session diff --git a/jobs/update-colin-filings/update_colin_filings.py b/jobs/update-colin-filings/update_colin_filings.py index 389a438b10..6c8d1555e3 100644 --- a/jobs/update-colin-filings/update_colin_filings.py +++ b/jobs/update-colin-filings/update_colin_filings.py @@ -34,8 +34,6 @@ event_level=logging.ERROR # send errors as events ) -requests_timeout = 20 - def create_app(run_mode=os.getenv('FLASK_ENV', 'production')): """Return a configured Flask App using the Factory method.""" @@ -64,6 +62,7 @@ def shell_context(): def get_filings(app: Flask, token, page, limit): """Get a filing with filing_id.""" + requests_timeout = int(app.config.get('ACCOUNT_SVC_TIMEOUT')) req = requests.get(f'{app.config["LEGAL_API_URL"]}/businesses/internal/filings?page={page}&limit={limit}', headers={'Authorization': 'Bearer ' + token}, timeout=requests_timeout) @@ -83,6 +82,7 @@ def send_filing(app: Flask, token: str, filing: dict, filing_id: str): req = None if legal_type and identifier and filing_type: + requests_timeout = int(app.config.get('ACCOUNT_SVC_TIMEOUT')) req = requests.post(f'{app.config["COLIN_URL"]}/{legal_type}/{identifier}/filings/{filing_type}', headers={'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token}, @@ -99,6 +99,7 @@ def send_filing(app: Flask, token: str, filing: dict, filing_id: str): def update_colin_id(app: Flask, token: dict, filing_id: str, colin_ids: list): """Update the colin_id in the filings table.""" + requests_timeout = int(app.config.get('ACCOUNT_SVC_TIMEOUT')) req = requests.patch( f'{app.config["LEGAL_API_URL"]}/businesses/internal/filings/{filing_id}', headers={'Authorization': 'Bearer ' + token}, @@ -126,6 +127,7 @@ def get_bearer_token(app): token_url = app.config.get('ACCOUNT_SVC_AUTH_URL') client_id = app.config.get('ACCOUNT_SVC_CLIENT_ID') client_secret = app.config.get('ACCOUNT_SVC_CLIENT_SECRET') + requests_timeout = int(app.config.get('ACCOUNT_SVC_TIMEOUT')) data = 'grant_type=client_credentials' @@ -148,7 +150,6 @@ def run(): corps_with_failed_filing = [] with application.app_context(): try: - requests_timeout = int(application.config.get('ACCOUNT_SVC_TIMEOUT')) # get updater-job token token = get_bearer_token(application) diff --git a/jobs/update-legal-filings/update_legal_filings.py b/jobs/update-legal-filings/update_legal_filings.py index abdd3c297e..a1569bb7ff 100644 --- a/jobs/update-legal-filings/update_legal_filings.py +++ b/jobs/update-legal-filings/update_legal_filings.py @@ -231,8 +231,7 @@ def update_filings(application): # pylint: disable=redefined-outer-name, too-ma else: # update max_event_id entered successful_filings += 1 - if int(event_info['event_id']) > max_event_id: - max_event_id = int(event_info['event_id']) + max_event_id = max(max_event_id, int(event_info['event_id'])) else: skipped_filings.append(event_info) else: @@ -276,7 +275,7 @@ def update_filings(application): # pylint: disable=redefined-outer-name, too-ma application.logger.error('Update-legal-filings: unhandled error %s', err) -async def publish_queue_events(tax_ids: dict, application: Flask): # pylint: disable=redefined-outer-name +async def publish_queue_events(qsm, tax_ids: dict, application: Flask): # pylint: disable=redefined-outer-name """Publish events for all businesses with new tax ids (for email + entity listeners).""" for identifier in tax_ids.keys(): try: @@ -307,7 +306,7 @@ async def publish_queue_events(tax_ids: dict, application: Flask): # pylint: di application.logger.error('Update-legal-filings: Failed to publish bn entity event for %s.', identifier) -async def update_business_nos(application): # pylint: disable=redefined-outer-name +async def update_business_nos(application, qsm): # pylint: disable=redefined-outer-name """Update the tax_ids for corps with new bn_15s.""" try: # get updater-job token @@ -357,7 +356,7 @@ async def update_business_nos(application): # pylint: disable=redefined-outer-n application.logger.error('legal-updater failed to update tax_ids in lear.') raise Exception # pylint: disable=broad-exception-raised - await publish_queue_events(tax_ids, application) + await publish_queue_events(qsm, tax_ids, application) application.logger.debug('Successfully updated tax ids in lear.') else: @@ -375,4 +374,4 @@ async def update_business_nos(application): # pylint: disable=redefined-outer-n update_filings(application) event_loop = asyncio.get_event_loop() qsm = QueueService(app=application, loop=event_loop) - event_loop.run_until_complete(update_business_nos(application)) + event_loop.run_until_complete(update_business_nos(application, qsm))