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

Merge 0.8-dev to master #393

Merged
merged 415 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
415 commits
Select commit Hold shift + click to select a range
86a2a0f
Make byname recursive to accommodate meta-multi-D entities
manuelma Oct 11, 2023
adf1ea5
Fix tests
manuelma Oct 11, 2023
cba5a2d
Fix fetch_more() Traceback after calling refresh_session()
soininen Oct 12, 2023
bd6cf40
FIx tests better
manuelma Oct 12, 2023
312ec0d
Fix fetch_more() Traceback after calling refresh_session() (#288)
soininen Oct 12, 2023
2581754
Make unsupported database dialects official
soininen Oct 12, 2023
ff63aa1
Make unsupported database dialects official - fix for 0.8 (#289)
soininen Oct 12, 2023
6d00079
Fix byname_iter
manuelma Oct 12, 2023
ee828d2
Merge remote-tracking branch 'origin/0.8-dev' into 0.8-dev
manuelma Oct 12, 2023
1f8f4c1
Improve MappedItem.merge to better find out there's nothing to update
manuelma Oct 13, 2023
5e62042
Introduce DBMapping.reset(), fix typos, make PublicItem serializable
manuelma Oct 14, 2023
4a4b833
Fix DBMapping.reset to also clear tables in cascade
manuelma Oct 15, 2023
a912992
Fix order in export_entities so clients stay the same
manuelma Oct 15, 2023
0344004
Fix mistake
manuelma Oct 15, 2023
a031b05
Introduce MappedItem._something_to_update
manuelma Oct 15, 2023
4cdbc77
Fix tests
manuelma Oct 15, 2023
be976a8
API to import multi-D entities where the elements are also multi-D ents
manuelma Oct 16, 2023
09baab5
Allow python-level filtering in get_items
manuelma Oct 17, 2023
02e489e
Remove confusing key parameter_name for ParameterDefinition
manuelma Oct 17, 2023
ef24e11
FIx attribute access
manuelma Oct 17, 2023
d1db6c9
Don't skip commit in item_types()
manuelma Oct 17, 2023
91c51e0
Introduce all_item_types to distinguish read-only stuff like commit
manuelma Oct 17, 2023
c7ae3f8
Fix tests
manuelma Oct 17, 2023
fee5e83
Support filtering in SQL via get_items
manuelma Oct 18, 2023
062697e
Fix importing object classes
manuelma Oct 18, 2023
05544b7
Lazy purge - instead of fetching the entire table just to purge it...
manuelma Oct 19, 2023
f7b7684
Add method to check if database has commits from other sources.
soininen Oct 19, 2023
edf8fb6
Add method to check if database has commits from other sources. (#292)
soininen Oct 20, 2023
b213b5a
Add CommitItem
soininen Oct 20, 2023
3a01e1d
Add CommitItem (#293)
soininen Oct 20, 2023
58cb7b4
Fix adding/updating values from list
manuelma Oct 20, 2023
f723d9a
Check _Index dimensions before comparison to avoid Traceback
soininen Oct 20, 2023
845384b
Check _Index dimensions before comparison to avoid Traceback (#297)
soininen Oct 20, 2023
73c24bc
Sanitize obsolete purge settings
manuelma Oct 21, 2023
24b40ec
Fix fetching entities that refer to unfetched entities
manuelma Oct 25, 2023
9650d01
Optimize fetching a little bit
manuelma Oct 25, 2023
1900a69
Progress tutorial
manuelma Oct 25, 2023
39d1cfa
Don't raise if cannot filter query, that's ok
manuelma Oct 26, 2023
b1def6d
First steps towards superclass_subclass
manuelma Oct 27, 2023
590fbc2
Add reference to superclass_name from entity
manuelma Oct 27, 2023
dc8ca6c
Register instances under superclass too
manuelma Oct 30, 2023
500c69f
Add multi-D instances with abstract dimensions
manuelma Oct 30, 2023
4ce5eef
Fix typo
manuelma Oct 30, 2023
a9f71fc
Export superclass subclasses
manuelma Oct 30, 2023
7aa4961
Add migration script to create the superclass_subclass table
manuelma Oct 30, 2023
09c7cc1
Complete test and fix typo
manuelma Oct 31, 2023
0ea0ee4
Fix creation of superclass_subclass table
manuelma Oct 31, 2023
0b16b3c
Fix unique keys of list value item
manuelma Oct 31, 2023
f7d5f59
Introduce MappedItem.check_mutability
manuelma Nov 2, 2023
302d6e1
Call check_mutability also for adding items
manuelma Nov 2, 2023
591d679
Add weak ref to superclass_subclass from entity_class
manuelma Nov 2, 2023
97e2451
Superclass-subclass (#301)
manuelma Nov 2, 2023
ade3e60
Fix importing scenario alternatives
soininen Nov 8, 2023
314c2b1
Fix importing out-of-order scenario alternatives for 0.8-dev (#303)
soininen Nov 8, 2023
5c38a21
Fix docs build and update tutorial
manuelma Nov 9, 2023
1b416d9
Introduce get_{item_type}_items convenience method for DatabaseMapping
manuelma Nov 9, 2023
3004d7a
Provide cascade_remove_items for legacy
manuelma Nov 9, 2023
1ff7a9c
Get rid of the ticket in fetch_more, let clients manage fetch completion
manuelma Nov 9, 2023
3b2b887
Accept filtering kwargs in fetch_more
manuelma Nov 9, 2023
786f961
Move db mapping schema to its own file
manuelma Nov 9, 2023
d0df284
Fix refs to the DB mapping schema
manuelma Nov 9, 2023
fc0d230
Introduce :meta private: so that autoapi skip some members
manuelma Nov 9, 2023
26012e9
Improve docs for the parameter_value module
manuelma Nov 10, 2023
fd5497c
Make remove_credentials_from_url() work with special characters
soininen Nov 14, 2023
3adfbce
Make remove_credentials_from_url() work with special characters (#308)
soininen Nov 14, 2023
55adad4
Add unit test for adding scenario alternatives
soininen Nov 16, 2023
570bceb
Add a unit test (#311)
soininen Nov 16, 2023
0f27399
Add methods to generate entity and entity class names
soininen Nov 17, 2023
cc90681
Make multidimensional entity naming more consistent (#313)
soininen Nov 17, 2023
9767aaa
Make SqlAlchemyConnector work with database schemas
soininen Nov 20, 2023
8bd6183
Make SqlAlchemyConnector work with database schemas (#315)
soininen Nov 21, 2023
633ce6d
Fix accessing table attributes using mapping names
manuelma Nov 21, 2023
313ad54
Undocument the check keyword argument to DatabaseMapping methods
manuelma Nov 21, 2023
90d4854
Introduce check_fields to do type checking in DatabaseMapping
manuelma Nov 21, 2023
32a23a8
Don't update equivalent entities in import_data
manuelma Nov 21, 2023
511a32e
Don't complain about None values when checking keyword args
manuelma Nov 22, 2023
4c85065
Very minor code refactoring
manuelma Nov 22, 2023
d4839dc
Fix check_fields
manuelma Nov 22, 2023
7749109
Add entities with multi-d dimensions by specifying all zero-d elements
manuelma Nov 23, 2023
10820b8
Add unique key (superclass_name, byname) for entity
manuelma Nov 23, 2023
158d7a8
Error whenever element count is not right
manuelma Nov 23, 2023
ab01cc8
Add element_byname_list key to entity
manuelma Nov 23, 2023
dd0d4dc
Fix type of hidden and add dimension_count to private fields of ent_cls
manuelma Nov 23, 2023
83f94e3
Introduce add_update and use it in import_data
manuelma Nov 24, 2023
04c38da
Fix export_data as per latest changes regarding multi d entities
manuelma Nov 24, 2023
efb8808
Merge branch '0.8-dev' into add_update
manuelma Nov 24, 2023
7c7713e
Fix test too
manuelma Nov 24, 2023
373f1b4
Merge branch '0.8-dev' into add_update
manuelma Nov 24, 2023
df9d246
Improve return type of add_update_item
manuelma Nov 27, 2023
29ce79e
Reset cache after clearing subqueries just in case
manuelma Nov 27, 2023
e96f513
Minor fixes: don't update removed items and always set list_value_id
manuelma Nov 27, 2023
c81f402
Merge branch '0.8-dev' into add_update
manuelma Nov 27, 2023
90caffe
Add docs and convenience add_update methods
manuelma Nov 27, 2023
0626567
Introduce add_update and use it in import_data (#320)
manuelma Nov 27, 2023
245d3c1
Add note about add_update to import_data documentation
manuelma Nov 27, 2023
b1f7c4c
Accept None when updating
manuelma Nov 29, 2023
fcd49bf
Simplify computation of time-series indices
manuelma Nov 29, 2023
e577113
Accept np.dtype as value_type for IndexedValue
manuelma Nov 29, 2023
8393b9b
Fix order of imports to combine legacy and non-legacy
manuelma Nov 29, 2023
3f785a0
Issue 2454 traceback from url bar (#326)
PiispaH Dec 13, 2023
4f56747
Make entity and value metadata use class_name as unique key
soininen Jan 5, 2024
cede1b2
Make entity and value metadata use class_name as unique key (#330)
soininen Jan 5, 2024
50ace91
Don't add commit ids to items that don't have them
soininen Jan 8, 2024
ede0812
Don't add commit ids to items that don't have them (#332)
soininen Jan 8, 2024
6959fd5
Implement rudimentary "merge conflict resolution"
soininen Dec 13, 2023
2225236
Use in-memory ids instead of database ids
soininen Dec 21, 2023
3e88fb4
Fix removing items using Asterisk as id
soininen Jan 11, 2024
92a2bf0
Use enity_byname consistently everywhere
soininen Jan 11, 2024
5e489d8
Rename 'class_name' fields to 'entity_class_name' for consistency
soininen Jan 11, 2024
0fe0362
Rename byname -> entity_byname, class_name -> entity_class_name (#334)
soininen Jan 11, 2024
356eb61
Merge branch '0.8-dev' into toolbox_2431_fix_fetching_external_modifi…
soininen Jan 11, 2024
86c2482
Fix tutorial
soininen Jan 12, 2024
7583f0d
Fix sphinx errors from the auto-generated db_mapping_schema.rst
soininen Jan 12, 2024
44b6883
Fix tutorial (#335)
soininen Jan 12, 2024
7441bfb
Add active_by_default flag to entity_class table
soininen Jan 15, 2024
1cea359
Fix opening infinite db editor tabs from same db (#337)
PiispaH Jan 15, 2024
8775ef0
Add active_by_default to import_functions and export_functions
soininen Jan 15, 2024
ab1b8e2
Fix unit tests
soininen Jan 15, 2024
43c1bb6
Add active_by_default flag to entity_class table (#336)
soininen Jan 17, 2024
89e44fd
Merge branch '0.8-dev' into toolbox_2431_fix_fetching_external_modifi…
soininen Jan 17, 2024
c874f42
Add changelog.
soininen Jan 23, 2024
508d814
Add changelog (#338)
soininen Jan 23, 2024
7fc383e
Fix typo in CHANGELOG.md
soininen Jan 23, 2024
782b041
Update copyright notices
soininen Jan 24, 2024
74d39ad
Fix database migration when database has no entity classes
soininen Jan 24, 2024
e4945db
Fix database migration when database has no multidimensional entity c…
soininen Jan 24, 2024
a97c794
Revert "Update copyright notices"
soininen Jan 24, 2024
9e7abb5
New version of cx_oracle is called oracledb
ptsavol Jan 30, 2024
2563b3b
Rewrite the pages about metadata in the docs
soininen Jan 30, 2024
474d3a7
Rewrite the pages about metadata in the docs (#340)
soininen Jan 30, 2024
d187d29
Make database mapping work when fetching external changes (#333)
soininen Jan 30, 2024
0bb592b
Update copyrights
soininen Jan 30, 2024
e9d10b4
Remove cx_oracle from requirements and 'oracle' from unsupported dial…
ptsavol Jan 30, 2024
4997faa
Update copyrights (#341)
soininen Jan 30, 2024
0f310f8
Remove cx_oracle from requirements (#342)
ptsavol Jan 30, 2024
58f12b3
Revert "Make database mapping work when fetching external changes (#3…
soininen Jan 31, 2024
2da3e72
Revert changes in PR 333 (#343)
soininen Jan 31, 2024
6cf762c
Speed up scenario filtered entity subquery
manuelma Feb 1, 2024
3c2c9a4
Fix commit
manuelma Feb 2, 2024
74c0021
Add test
manuelma Feb 2, 2024
a64128d
Add conversion from is_active default values to active_by_default
soininen Feb 2, 2024
2fa0c3b
Fix updating entity alternatives by compatibility transforms
soininen Feb 2, 2024
30fc985
Use the default value for is_active when migrating to active_by_defau…
soininen Feb 2, 2024
0bc2aac
Fix locking, solve conflicts, add tests
manuelma Feb 2, 2024
05e0beb
Fix check for uniqueness
manuelma Feb 2, 2024
92608b8
Fix check for uniqueness better
manuelma Feb 2, 2024
0339d1d
Fix typo
manuelma Feb 2, 2024
8fc4ef4
Fix commit (#346)
manuelma Feb 2, 2024
6b5287b
Skip faulty test on windows
manuelma Feb 2, 2024
4bf93d7
Skip tests more aggressively
manuelma Feb 2, 2024
7fa63d3
Fix decorator
manuelma Feb 2, 2024
28b4a68
Trying out things
manuelma Feb 2, 2024
02130ed
Enhance unit tests; add DatabaseMappingBase.reset_purging()
soininen Feb 5, 2024
b92facd
Enable resetting purge and enhance unit tests (#349)
soininen Feb 5, 2024
7760b31
Keep removed items's unique key values for conflict resolution
manuelma Feb 5, 2024
237e1c8
Merge remote-tracking branch 'origin/0.8-dev' into fix-conflicts
manuelma Feb 5, 2024
282d38e
Allow the restoration of purged items one-by-one.
soininen Feb 5, 2024
eaba7d2
Introduce _free_id
manuelma Feb 5, 2024
02a953f
Add tests
manuelma Feb 5, 2024
c6ba41d
Fix checking if db-item and mapped-item with same id have same uq-keys
manuelma Feb 6, 2024
cc2af3f
Notify clients of updating ids
manuelma Feb 6, 2024
d934cd0
Fetch referred types whenever there are external commits
manuelma Feb 6, 2024
fb68b5e
Minimize refetches when DB has external commits
manuelma Feb 7, 2024
220ae18
Improve check for db-item equals to mapped-item
manuelma Feb 7, 2024
87fa8d8
Fix performance issue due to distrusting the DB too much
manuelma Feb 7, 2024
9fd3eb8
Add tests for DatabaseMapping.
soininen Feb 7, 2024
a5058d0
Merge remote-tracking branch 'origin/tests_for_fix_conflicts' into fi…
manuelma Feb 7, 2024
459d350
Use TempId for all items in the mapping
manuelma Feb 7, 2024
c33f91b
Fix scenario filter for entity alternatives
soininen Feb 8, 2024
8efd5af
Fix scenario filter for entity alternatives (#352)
soininen Feb 8, 2024
4d67fd6
Allow the restoration of purged items one-by-one. (#351)
soininen Feb 8, 2024
0544df8
Merge remote-tracking branch 'origin/0.8-dev' into fix-conflicts
manuelma Feb 8, 2024
8b91a0d
Fix MappedItemBase.update to keep the previous id as a TempId
manuelma Feb 8, 2024
ae7f158
Fix tests
manuelma Feb 8, 2024
518f60a
Update mapped item status in detach
manuelma Feb 8, 2024
5359197
Fix check for item equivalency
manuelma Feb 8, 2024
27a3c6b
Rename one method for clarity
manuelma Feb 8, 2024
d467319
Don't fetch_all the same data twice
manuelma Feb 9, 2024
20ba7ad
Fix import scenario_alternatives
manuelma Feb 9, 2024
404b984
Merge remote-tracking branch 'origin/0.8-dev' into fix-conflicts
manuelma Feb 9, 2024
a4313d5
Consistently set the removal source for lazy purge too
manuelma Feb 11, 2024
40d86c8
Merge remote-tracking branch 'origin/0.8-dev' into fix-conflicts
manuelma Feb 11, 2024
fef05b9
Update Github action
ptsavol Feb 12, 2024
0f33669
Accept external changes if they were done after committing ours
manuelma Feb 12, 2024
db1a150
Internal conflict resolution (#350)
manuelma Feb 12, 2024
7e4c061
Fix TempId.__new__ to make it picklable
manuelma Feb 12, 2024
4178308
Fix issues with pickling TempIds
manuelma Feb 12, 2024
dad322e
Don't show removed stuff after a refresh
manuelma Feb 12, 2024
2e31fdb
Add Spine Toolbox unit and execution tests to GitHub workflows
soininen Feb 12, 2024
115f3ee
Add Spine Toolbox unit and execution tests to GitHub workflows (#360)
soininen Feb 13, 2024
bf575a4
Add index_name to Parameter value format documentation
soininen Feb 13, 2024
8a31dc7
Add index_name to Parameter value format documentation (#361)
soininen Feb 13, 2024
eb0d64a
Fix TempId.__hash__ to follow python rules
manuelma Feb 14, 2024
956ad39
Add one unit-test for 'difficult' refresh
manuelma Feb 14, 2024
efa0a0f
Fix TempId.__hash__ to follow python rules (#362)
manuelma Feb 14, 2024
50f41d2
Implement __lt__ for TempId
manuelma Feb 16, 2024
c3830de
Fix graph view not drawing anything
Feb 16, 2024
cfedb0b
Fix graph view not drawing anything (#365)
PiispaH Feb 16, 2024
40d8ab9
Remove duplicate of method
Feb 16, 2024
549b2cb
Resolve values before setting query filters
manuelma Feb 16, 2024
aaa889d
Introduce MappedItemBase.validate
manuelma Feb 18, 2024
6b48807
Introduce API to backup DBs
manuelma Feb 19, 2024
28f79cd
Introduce API to backup DBs (#366)
manuelma Feb 19, 2024
204edd4
Remove 'do not upgrade' as an option
manuelma Feb 20, 2024
4b8ef69
Lock sqlite DB before upgrade
manuelma Feb 20, 2024
d806612
Fix engine creation for DB mapping when also creating the DB
manuelma Feb 21, 2024
38b44a4
Only use existing tools when migrating, not when committing
manuelma Feb 21, 2024
3d6c409
Only use existing tools when migrating, not when committing (#367)
manuelma Feb 21, 2024
30fdba0
Try and make sure TempIds work with the DB Server
manuelma Feb 23, 2024
42c3644
Make sure all ids are replaced by TempId in referrers
manuelma Feb 23, 2024
8666dc8
Merge branch '0.8-dev' into temp_id_over_the_server
manuelma Feb 23, 2024
98561f7
Add some tests for the DB server
manuelma Feb 23, 2024
9415645
Temp id over the server (#369)
manuelma Feb 23, 2024
8580b06
Set active_by_default to true when migrating if is_active is missing
soininen Feb 26, 2024
c38a9a2
Set active_by_default to true when migrating if is_active is missing …
soininen Feb 26, 2024
20ec2ad
Fix time-series db export
Mar 8, 2024
2d8295e
Fix time-series db export (#373)
PiispaH Mar 8, 2024
909eccd
Separate unique id creation from TempId initialization
soininen Mar 8, 2024
5f8052d
Separate unique id creation from TempId initialization (#374)
soininen Mar 8, 2024
6900895
Fix entity dimension, value_type -fields in Excel exports
Mar 11, 2024
7fe60ec
Make compatibility transform optional on commit
soininen Mar 12, 2024
5840d4b
Make compatibility transforms optional on commit (#375)
soininen Mar 12, 2024
56a6a78
Add deep_copy_value() function
soininen Mar 25, 2024
340f587
Add deep_copy_value() function (#377)
soininen Mar 25, 2024
c5b8d2f
Add some performance benchmarks
soininen Mar 27, 2024
1585480
Avoid parsing parameter value when checking need for update
soininen Mar 13, 2024
505c7ee
Make updating parameter (default) values faster and add benchmarks (#…
soininen Mar 28, 2024
0106526
Add a function to create default import mappings
soininen Apr 2, 2024
09b2edc
Improve purge_url() and purge() docstrings.
soininen Apr 2, 2024
ca54884
Add functions to generate default import mappings (#379)
soininen Apr 2, 2024
2cccc95
Enable string normalization in black
soininen Apr 2, 2024
a427173
Enable string normalization in Black (#380)
soininen Apr 2, 2024
5bd4c45
Lift Python version upper limit
soininen Jan 25, 2024
0cc12df
Lift the upper limit for Python version (#381)
soininen Apr 2, 2024
a6fb829
Make deep_copy_value() accept None
soininen Apr 5, 2024
ade116a
deep_copy_value() to accept None (#383)
soininen Apr 5, 2024
b305184
Fix typo in benchmarks/README.md link
soininen Apr 9, 2024
770d6db
Fix benchmarks and add new ones
soininen Apr 9, 2024
d54ebe9
Remove the entity_type field form Excel exports
Apr 10, 2024
0c59f43
Remove the entity_type field form Excel exports (#387)
PiispaH Apr 10, 2024
b219ceb
Try datetime.fromisoformat() before falling back to dateutil.parser.p…
soininen Apr 10, 2024
3c2b4b4
Improve time stamp parsing performance (#388)
soininen Apr 10, 2024
9263b66
Add more benchmarks
soininen Apr 11, 2024
2cf8dcb
Add more benchmarks (#389)
soininen Apr 11, 2024
7e940a7
Fix example in docstring, improve tutorial
soininen Apr 11, 2024
12f28fb
Fix example in docstring, improve tutorial (#390)
soininen Apr 11, 2024
0ce27d4
Bump Spine DB Server and cliend versions from 6 to 7
soininen Apr 23, 2024
eddedca
Bump Spine DB Server and cliend versions from 6 to 7 (#391)
soininen Apr 23, 2024
29e89b0
Don't forcefully write benchmark results on disk
soininen Apr 24, 2024
cd995e0
Merge branch '0.8-dev' into toolbox_2629_merge_0.8
soininen Apr 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 89 additions & 7 deletions .github/workflows/run_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ name: Unit tests

# Run workflow on every push
on:
push
push:
paths:
- "**.py"
- "requirements.txt"
- "pyproject.toml"
- ".github/workflows/*.yml"

jobs:
unit-tests:
Expand All @@ -13,15 +18,15 @@ jobs:
strategy:
matrix:
os: [ubuntu-22.04, windows-latest]
python-version: [3.8, 3.9, "3.10", 3.11]
python-version: [3.8, 3.9, "3.10", 3.11, 3.12]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Version from Git tags
run: git describe --tags
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
Expand All @@ -36,14 +41,91 @@ jobs:
PYTHONUTF8: 1
run: |
python -m pip install --upgrade pip
pip install .[dev]
python -m pip install .[dev]
- name: List packages
run:
pip list
python -m pip list
- name: Run tests
env:
QT_QPA_PLATFORM: offscreen
run:
coverage run -m unittest discover --verbose
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
toolbox-unit-tests:
name: Spine Toolbox unit tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
python-version: [3.8]
os: [ubuntu-22.04]
steps:
- uses: actions/checkout@v4
with:
repository: spine-tools/Spine-Toolbox
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install additional packages for Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update -y
sudo apt-get install -y libegl1
- name: Install dependencies
env:
PYTHONUTF8: 1
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
- name: List packages
run:
python -m pip list
- name: Install python3 kernelspecs
run: |
python -m pip install ipykernel
python -m ipykernel install --user
- name: Run tests
run: |
if [ "$RUNNER_OS" != "Windows" ]; then
export QT_QPA_PLATFORM=offscreen
fi
python -m unittest discover --verbose
shell: bash
toolbox-execution-tests:
name: Spine Toolbox execution tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [3.8]
os: [ubuntu-22.04]
steps:
- uses: actions/checkout@v4
with:
repository: spine-tools/Spine-Toolbox
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install additional packages for Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update -y
sudo apt-get install -y libegl1
- name: Install dependencies
env:
PYTHONUTF8: 1
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
- name: List packages
run:
python -m pip list
- name: Run tests
run:
python -m unittest discover --pattern execution_test.py --verbose
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/.idea/
/docs/build/
/docs/source/autoapi/
/docs/source/db_mapping_schema.rst

# Setuptools distribution folder.
/build/
Expand All @@ -16,3 +17,4 @@
/htmlcov

spinedb_api/version.py
benchmarks/*.json
10 changes: 7 additions & 3 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.9"

# Build documentation in the docs/ directory with Sphinx
sphinx:
builder: html
Expand All @@ -17,8 +23,6 @@ formats:

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.8
install:
- method: pip
path: .
- requirements: requirements.txt
- requirements: docs/requirements.txt
39 changes: 39 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

This is the first release where we keep a Spine-Database-API specific changelog.

The database structure has changed quite a bit.
Large parts of the API have been rewritten or replaced by new systems.
We are still keeping many old entry points for backwards compatibility,
but those functions and methods are pending deprecation.

### Changed

- Python 3.12 is now supported.
- Objects and relationships have been replaced by *entities*.
Zero-dimensional entities correspond to objects while multidimensional entities to relationships.

### Added

- *Entity alternatives* control the visibility of entities.
This replaces previous tools, features and methods.
- Support for *superclasses*.
It is now possible to set a superclass for an entity class.
The class then inherits parameter definitions from its superclass.

### Fixed

### Removed

- Tools, features and methods have been removed.

### Deprecated

### Security
29 changes: 29 additions & 0 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Performance benchmarks

This Python package contains performance benchmarks for `spinedb_api`.
The benchmarks use [`pyperf`](https://pyperf.readthedocs.io/en/latest/index.html)
which is installed as part of the optional developer dependencies:

```commandline
python -mpip install -e .[dev]
```

Each Python file is a self-contained script
that benchmarks some aspect of the DB API.
Benchmark results can be optionally written into a`.json` file
by modifying the script.
This may be handy for comparing different branches/commits/changes etc.
The file can be inspected by

```commandline
python -mpyperf show <benchmark file.json>
```

Benchmark files from e.g. different commits/branches can be compared by

```commandline
python -mpyperf compare_to <benchmark file 1.json> <benchmark file 2.json>
```

Check the [`pyperf` documentation](https://pyperf.readthedocs.io/en/latest/index.html)
for further things you can do with it.
Empty file added benchmarks/__init__.py
Empty file.
55 changes: 55 additions & 0 deletions benchmarks/datetime_from_database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""
This benchmark tests the performance of reading a DateTime value from database.
"""

import datetime
import time
from typing import Any, Sequence, Tuple
import pyperf
from spinedb_api import DateTime, from_database, to_database


def build_datetimes(count: int) -> Sequence[DateTime]:
datetimes = []
year = 2024
month = 1
day = 1
hour = 0
while len(datetimes) != count:
datetimes.append(DateTime(datetime.datetime(year, month, day, hour)))
hour += 1
if hour == 24:
hour = 0
day += 1
if day == 29:
day = 1
month += 1
if month == 13:
month = 1
year += 1
return datetimes


def value_from_database(loops: int, db_values_and_types: Sequence[Tuple[Any, str]]) -> float:
duration = 0.0
for _ in range(loops):
for db_value, db_type in db_values_and_types:
start = time.perf_counter()
from_database(db_value, db_type)
duration += time.perf_counter() - start
return duration


def run_benchmark(file_name):
runner = pyperf.Runner(loops=10)
inner_loops = 1000
db_values_and_types = [to_database(x) for x in build_datetimes(inner_loops)]
benchmark = runner.bench_time_func(
"from_database[DateTime]", value_from_database, db_values_and_types, inner_loops=inner_loops
)
if file_name:
pyperf.add_runs(file_name, benchmark)


if __name__ == "__main__":
run_benchmark("")
39 changes: 39 additions & 0 deletions benchmarks/map_from_database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""
This benchmark tests the performance of reading a Map type value from database.
"""

import time
import pyperf
from spinedb_api import from_database, to_database
from benchmarks.utils import build_even_map


def value_from_database(loops, db_value, value_type):
duration = 0.0
for _ in range(loops):
start = time.perf_counter()
from_database(db_value, value_type)
duration += time.perf_counter() - start
return duration


def run_benchmark(file_name):
runner = pyperf.Runner(loops=3)
runs = {
"value_from_database[Map(10, 10, 100)]": {"dimensions": (10, 10, 100)},
"value_from_database[Map(1000)]": {"dimensions": (10000,)},
}
for name, parameters in runs.items():
db_value, value_type = to_database(build_even_map(parameters["dimensions"]))
benchmark = runner.bench_time_func(
name,
value_from_database,
db_value,
value_type,
)
if file_name and benchmark is not None:
pyperf.add_runs(file_name, benchmark)


if __name__ == "__main__":
run_benchmark("")
61 changes: 61 additions & 0 deletions benchmarks/mapped_item_getitem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"""
This benchmark tests the performance of the MappedItemBase.__getitem__() method.
"""

import pyperf
import time
from typing import Dict
from spinedb_api import DatabaseMapping
from spinedb_api.db_mapping_base import PublicItem


def use_subscript_operator(loops: int, items: PublicItem, field: Dict):
duration = 0.0
for _ in range(loops):
for item in items:
start = time.perf_counter()
value = item[field]
duration += time.perf_counter() - start
return duration


def run_benchmark(file_name):
runner = pyperf.Runner()
inner_loops = 1000
object_class_names = [str(i) for i in range(inner_loops)]
relationship_class_names = [f"r{dimension}" for dimension in object_class_names]
with DatabaseMapping("sqlite://", create=True) as db_map:
object_classes = []
for name in object_class_names:
item, error = db_map.add_entity_class_item(name=name)
assert error is None
object_classes.append(item)
relationship_classes = []
for name, dimension in zip(relationship_class_names, object_classes):
item, error = db_map.add_entity_class_item(name, dimension_name_list=(dimension["name"],))
assert error is None
relationship_classes.append(item)
benchmarks = [
runner.bench_time_func(
"PublicItem subscript['name' in EntityClassItem]",
use_subscript_operator,
object_classes,
"name",
inner_loops=inner_loops,
),
runner.bench_time_func(
"PublicItem subscript['dimension_name_list' in EntityClassItem]",
use_subscript_operator,
relationship_classes,
"dimension_name_list",
inner_loops=inner_loops,
),
]
if file_name:
for benchmark in benchmarks:
if benchmark is not None:
pyperf.add_runs(file_name, benchmark)


if __name__ == "__main__":
run_benchmark("")
Loading
Loading