Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Base Worker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Workers
Base Worker
Commits
05f51298
Commit
05f51298
authored
3 years ago
by
Eva Bardou
Browse files
Options
Downloads
Patches
Plain Diff
Add Erwan's suggestions
parent
bce57a31
No related branches found
No related tags found
No related merge requests found
Pipeline
#79044
passed
3 years ago
Stage: test
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arkindex_worker/cache.py
+17
-14
17 additions, 14 deletions
arkindex_worker/cache.py
with
17 additions
and
14 deletions
arkindex_worker/cache.py
+
17
−
14
View file @
05f51298
...
...
@@ -13,6 +13,7 @@ from peewee import (
ForeignKeyField
,
IntegerField
,
Model
,
OperationalError
,
SqliteDatabase
,
TextField
,
UUIDField
,
...
...
@@ -217,25 +218,27 @@ def create_tables():
def
create_version_table
():
"""
Creates the Version table in the cache DB.
This step must be independent from other tables creation since we only
want to create the table and add the one and only Version entry when the
cache is created from scratch.
"""
db
.
create_tables
([
Version
])
Version
.
create
(
version
=
SQL_VERSION
)
def
check_version
(
cache_path
):
provided_db
=
sqlite3
.
connect
(
cache_path
)
provided_db
.
row_factory
=
sqlite3
.
Row
cursor
=
provided_db
.
cursor
()
try
:
db_results
=
cursor
.
execute
(
SQL_VERSION_QUERY
).
fetchall
()
except
sqlite3
.
OperationalError
:
db_results
=
[]
assert
(
len
(
db_results
)
==
1
and
db_results
[
0
][
"
version
"
]
==
SQL_VERSION
),
f
"
The SQLite database
{
cache_path
}
does not have the correct cache version, it should be
{
SQL_VERSION
}
"
provided_db
.
close
()
with
SqliteDatabase
(
cache_path
)
as
provided_db
:
with
provided_db
.
bind_ctx
([
Version
]):
try
:
version
=
Version
.
get
().
version
except
OperationalError
:
version
=
None
assert
(
version
==
SQL_VERSION
),
f
"
The SQLite database
{
cache_path
}
does not have the correct cache version, it should be
{
SQL_VERSION
}
"
def
retrieve_parents_cache_path
(
parent_ids
,
data_dir
=
"
/data
"
,
chunk
=
None
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment