Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
vysakh-menon-aot committed Aug 6, 2024
1 parent 3956d8e commit cb64a2a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions jobs/future-effective-filings/file_future_effective.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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()


Expand Down
1 change: 0 additions & 1 deletion jobs/future-effective-filings/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions jobs/update-colin-filings/update_colin_filings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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)
Expand All @@ -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},
Expand All @@ -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},
Expand Down Expand Up @@ -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'

Expand All @@ -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)

Expand Down
11 changes: 5 additions & 6 deletions jobs/update-legal-filings/update_legal_filings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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))

0 comments on commit cb64a2a

Please sign in to comment.