Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unfreeze SQLAlchemy #252

Closed
wants to merge 13 commits into from
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
- Add missing brew path to GitHub action. It has been removed from PATH variable in Ubuntu
- Badges on README page
- Unfreeze SQLAlchemy again, allowing >=1.3 as the limitation in chanjo-report is being fixed

## [4.6.1] - 2021-07-08
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion chanjo/init/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ def pull(target_dir, force=False): # pragma: no cover
logger.info('removing BED archive...')
bed_zip_path.remove_p()
else:
logger.warn('file already exists, skipping: %s', final_bed)
logger.warning('file already exists, skipping: %s', final_bed)
2 changes: 1 addition & 1 deletion chanjo/init/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def setup_demo(location, force=False):
# we can copy the directory(tree)
demo_dir.copytree(target_dir)
except OSError as error:
log.warn('location must be a non-existing directory')
log.warning('location must be a non-existing directory')
raise error

# inform the user
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ toolz
pyyaml
importlib_metadata
pymysql
sqlalchemy==1.3.*
Copy link
Member

@northwestwitch northwestwitch May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sqlalchemy 2 can be quite different from v.1, there is even a migration guide: https://docs.sqlalchemy.org/en/20/changelog/migration_20.html

Just unfreezing like this seems risky..

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I realised a little while ago. 😊 It was useful to test the dependencies at least: nice to see that chanjo-report / scout did build and run ok with this configuration. But chanjo would likely bug out without changes..

sqlalchemy<2.0
10 changes: 5 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from chanjo.load.link import link_elements


@pytest.yield_fixture
@pytest.fixture
def reset_path():
"""Reset PATH environment variable temporarily."""
path_env = os.environ['PATH']
Expand All @@ -22,15 +22,15 @@ def reset_path():
os.environ['PATH'] = path_env


@pytest.yield_fixture(scope='function')
@pytest.fixture(scope='function')
def chanjo_db():
_chanjo_db = ChanjoDB('sqlite://')
_chanjo_db.set_up()
yield _chanjo_db
_chanjo_db.tear_down()


@pytest.yield_fixture(scope='function')
@pytest.fixture(scope='function')
def existing_db(tmpdir):
db_path = tmpdir.join('coverage.sqlite3')
chanjo_db = ChanjoDB(str(db_path))
Expand All @@ -39,7 +39,7 @@ def existing_db(tmpdir):
chanjo_db.tear_down()


@pytest.yield_fixture(scope='function')
@pytest.fixture(scope='function')
def popexist_db(existing_db, exon_lines):
result = link_elements(exon_lines)
existing_db.add(*result.models)
Expand All @@ -50,7 +50,7 @@ def popexist_db(existing_db, exon_lines):
yield existing_db


@pytest.yield_fixture(scope='function')
@pytest.fixture(scope='function')
def populated_db(chanjo_db, exon_lines):
exon_lines = list(exon_lines)
result = link_elements(exon_lines)
Expand Down
6 changes: 3 additions & 3 deletions tests/store/test_store_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from datetime import datetime

import pytest
from sqlalchemy.orm.exc import FlushError
from sqlalchemy.exc import IntegrityError
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯


from chanjo.store.api import ChanjoDB
from chanjo.store.models import Sample
Expand Down Expand Up @@ -38,8 +38,8 @@ def test_save(chanjo_db):
# GIVEN sample already exists
conflict_sample = Sample(id=sample_id, group_id="ADMG2")
# WHEN saving it again with same id
# THEN error is raised _after_ rollback
with pytest.raises(FlushError):
# THEN an error is raised
with pytest.raises(IntegrityError):
chanjo_db.add(conflict_sample)
chanjo_db.save()

Expand Down