Skip to content

Commit bca3d63

Browse files
panish16claude
andcommitted
revert colin-api EOL dependency and Flask 3.x changes — Entity team will handle the full Python version upgrade separately
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 28127e5 commit bca3d63

9 files changed

Lines changed: 53 additions & 38 deletions

File tree

‎colin-api/Dockerfile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.9
1+
FROM python:3.8
22

33
ARG VCS_REF="missing"
44
ARG BUILD_DATE="missing"
@@ -13,7 +13,7 @@ USER root
1313

1414
# Installing Oracle instant client
1515
WORKDIR /opt/oracle
16-
RUN apt-get update && apt-get install -y libaio1t64 gdb wget unzip \
16+
RUN apt-get update && apt-get install -y libaio1 gdb wget unzip \
1717
&& wget https://download.oracle.com/otn_software/linux/instantclient/211000/instantclient-basiclite-linux.x64-21.1.0.0.0.zip \
1818
&& wget https://download.oracle.com/otn_software/linux/instantclient/211000/instantclient-sqlplus-linux.x64-21.1.0.0.0.zip \
1919
&& unzip instantclient-basiclite-linux.x64-21.1.0.0.0.zip \

‎colin-api/Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ clean-test: ## clean test files
3737
rm -fr htmlcov/
3838

3939
build-req: clean ## Upgrade requirements
40-
test -f venv/bin/activate || python3.9 -m venv $(CURRENT_ABS_DIR)/venv ;\
40+
test -f venv/bin/activate || python3.8 -m venv $(CURRENT_ABS_DIR)/venv ;\
4141
. venv/bin/activate ;\
4242
pip install --upgrade pip ;\
4343
pip install -Ur requirements/prod.txt ;\
@@ -46,7 +46,7 @@ build-req: clean ## Upgrade requirements
4646
pip install -Ur requirements/bcregistry-libraries.txt
4747

4848
install: clean ## Install python virtual environment
49-
test -f venv/bin/activate || python3.9 -m venv $(CURRENT_ABS_DIR)/venv ;\
49+
test -f venv/bin/activate || python3.8 -m venv $(CURRENT_ABS_DIR)/venv ;\
5050
. venv/bin/activate ;\
5151
pip install --upgrade pip ;\
5252
pip install -Ur requirements.txt

‎colin-api/requirements.txt‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11

22
Flask-Moment==0.11.0
33
Flask-Script==2.0.6
4-
Flask==3.0.3
5-
Jinja2==3.1.6
6-
MarkupSafe==2.1.5
7-
Werkzeug==3.0.6
4+
Flask==1.1.2
5+
Jinja2==2.11.3
6+
MarkupSafe==1.1.1
7+
Werkzeug==1.0.1
88
aniso8601==9.0.1
9-
blinker==1.8.2
9+
blinker==1.4
1010
certifi==2020.12.5
1111
click==8.1.3
1212
cx-Oracle==8.1.0
1313
datedelta==1.3
1414
debugpy
1515
ecdsa==0.14.1
16-
flask-jwt-oidc==0.8.0
17-
flask-restx==1.3.0
16+
flask-jwt-oidc==0.3.0
17+
flask-restx==0.3.0
1818
gunicorn==20.1.0
19-
itsdangerous==2.2.0
19+
itsdangerous==1.1.0
2020
jsonschema==4.19.0
2121
launchdarkly-server-sdk==7.1.0
2222
psycopg2-binary==2.8.6
@@ -28,7 +28,7 @@ python-jose==3.2.0
2828
pytz==2021.1
2929
requests==2.25.1
3030
rsa==4.7.2
31-
SQLAlchemy==2.0.40
32-
six==1.16.0
31+
SQLAlchemy==1.4.44
32+
six==1.15.0
3333
urllib3==1.26.11
3434
git+https://github.com/bcgov/business-schemas.git#egg=registry_schemas

‎colin-api/requirements/dev.txt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pytest-mock
66
pytest-cov
77
requests
88
pyhamcrest
9-
sqlalchemy>=2.0.0,<3.0.0
9+
sqlalchemy<=1.4.44
1010

1111
# Lint and code style
1212
flake8
@@ -21,5 +21,5 @@ coverage
2121
pydocstyle<4.0
2222
pylint
2323
pylint-flask
24-
isort>=5.0.0
25-
sqlalchemy>=2.0.0,<3.0.0
24+
isort<5,>=4.2.5
25+
sqlalchemy<=1.4.44

‎colin-api/setup.cfg‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,14 @@ notes=FIXME,XXX,TODO
7171
ignored-modules=flask_sqlalchemy,sqlalchemy,SQLAlchemy,alembic,scoped_session
7272
ignored-classes=scoped_session
7373
min-similarity-lines=100
74-
disable=C0301,W0511,R0801,R0902,E1136,R0917,C0411
74+
disable=C0301,W0511,R0801,R0902,E1136
7575

7676
[isort]
7777
line_length = 120
7878
indent = 4
7979
multi_line_output = 4
8080
lines_after_imports = 2
8181
include_trailing_comma = True
82-
known_first_party = colin_api
83-
known_third_party = cx_Oracle,flask,flask_jwt_oidc,flask_restx,ldclient,pytz,requests,sqlalchemy
8482

8583
[tool:pytest]
8684
addopts = --cov=src --cov-report html:htmlcov --cov-report xml:coverage.xml

‎colin-api/src/colin_api/config.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class _Config: # pylint: disable=too-few-public-methods
7474

7575
# JWT_OIDC Settings
7676
JWT_OIDC_WELL_KNOWN_CONFIG = os.getenv('JWT_OIDC_WELL_KNOWN_CONFIG')
77-
JWT_OIDC_ALGORITHMS = os.getenv('JWT_OIDC_ALGORITHMS', 'RS256')
77+
JWT_OIDC_ALGORITHMS = os.getenv('JWT_OIDC_ALGORITHMS')
7878
JWT_OIDC_JWKS_URI = os.getenv('JWT_OIDC_JWKS_URI')
7979
JWT_OIDC_ISSUER = os.getenv('JWT_OIDC_ISSUER')
8080
JWT_OIDC_AUDIENCE = os.getenv('JWT_OIDC_AUDIENCE')

‎colin-api/src/colin_api/models/filing.py‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,26 @@
2525
from flask import current_app
2626
from registry_schemas.utils import get_schema
2727

28-
from colin_api.exceptions import (
29-
FilingNotFoundException, GenericException, InvalidFilingTypeException, OfficeNotFoundException,
30-
PartiesNotFoundException, UnableToDetermineCorpTypeException,)
31-
from colin_api.models import (
32-
Address, Business, ContOut, CorpInvolved, CorpName, FilingType, Jurisdiction, Office, Party, ShareObject,)
28+
from colin_api.exceptions import ( # noqa: I001
29+
FilingNotFoundException, # noqa: I001
30+
GenericException, # noqa: I001
31+
InvalidFilingTypeException, # noqa: I001
32+
OfficeNotFoundException, # noqa: I001
33+
PartiesNotFoundException, # noqa: I001
34+
UnableToDetermineCorpTypeException, # noqa: I001
35+
) # noqa: I001
36+
from colin_api.models import ( # noqa: I001
37+
Address, # noqa: I001
38+
Business, # noqa: I001
39+
ContOut, # noqa: I001
40+
CorpInvolved, # noqa: I001
41+
CorpName, # noqa: I001
42+
FilingType, # noqa: I001
43+
Jurisdiction, # noqa: I001
44+
Office, # noqa: I001
45+
Party, # noqa: I001
46+
ShareObject, # noqa: I001
47+
) # noqa: I001
3348
from colin_api.resources.db import DB
3449
from colin_api.utils import convert_to_json_date, convert_to_json_datetime, convert_to_pacific_time, convert_to_snake
3550

‎colin-api/src/colin_api/resources/db.py‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
These will get initialized by the application.
1717
"""
1818
import cx_Oracle
19-
from flask import current_app, g
19+
from flask import _app_ctx_stack, current_app
2020

2121

2222
class OracleDB:
@@ -37,10 +37,11 @@ def init_app(self, app):
3737
app.teardown_appcontext(self.teardown)
3838

3939
@staticmethod
40-
def teardown(exception): # pylint: disable=unused-argument
40+
def teardown():
4141
"""Oracle session pool cleans up after itself."""
42-
if hasattr(g, '_oracle_pool'):
43-
g._oracle_pool.close() # pylint: disable=protected-access
42+
ctx = _app_ctx_stack.top
43+
if hasattr(ctx, 'oracle_pool'):
44+
ctx.oracle_pool.close()
4445

4546
@staticmethod
4647
def _create_pool():
@@ -77,17 +78,19 @@ def init_session(conn, *args): # pylint: disable=unused-argument; Extra var bei
7778
nencoding='UTF-8')
7879

7980
@property
80-
def connection(self):
81+
def connection(self): # pylint: disable=inconsistent-return-statements
8182
"""Create connection property for the NROService.
8283
8384
If this is running in a Flask context,
8485
then either get the existing connection pool or create a new one
8586
and then return an acquired session
8687
:return: cx_Oracle.connection type
8788
"""
88-
if not hasattr(g, '_oracle_pool'):
89-
g._oracle_pool = self._create_pool() # pylint: disable=protected-access
90-
return g._oracle_pool.acquire() # pylint: disable=protected-access
89+
ctx = _app_ctx_stack.top
90+
if ctx is not None:
91+
if not hasattr(ctx, '_oracle_pool'):
92+
ctx._oracle_pool = self._create_pool() # pylint: disable = protected-access; need this method
93+
return ctx._oracle_pool.acquire() # pylint: disable = protected-access; need this method
9194

9295

9396
# export instance of this class

‎colin-api/src/colin_api/services/flags.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
# limitations under the License.
1414
"""Manage the Feature Flags initialization, setup and service."""
1515
from flask import current_app
16-
from ldclient import get as ldclient_get # noqa: I001
17-
from ldclient import set_config as ldclient_set_config
16+
from ldclient import get as ldclient_get, set_config as ldclient_set_config # noqa: I001
1817
from ldclient.config import Config # noqa: I005
1918
from ldclient.impl.integrations.files.file_data_source import _FileDataSource
2019
from ldclient.interfaces import UpdateProcessor
@@ -65,9 +64,9 @@ def init_app(self, app):
6564
self.app = app
6665
self.sdk_key = app.config.get('LD_SDK_KEY')
6766

68-
if self.sdk_key or app.debug or app.testing:
67+
if self.sdk_key or app.env != 'production':
6968

70-
if not app.debug and not app.testing:
69+
if app.env == 'production':
7170
config = Config(sdk_key=self.sdk_key)
7271
else:
7372
factory = FileDataSource.factory(paths=['flags.json'],

0 commit comments

Comments
 (0)