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

allow arbitrary resource definitions #87

Merged
merged 25 commits into from
Jul 9, 2024
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2643e5f
allow arbitrary resource definitions
pedohorse Jun 23, 2024
adc5a87
implement arbitrary resource display
pedohorse Jun 23, 2024
0935226
add __repr__ __eq__ to WorkerResources
pedohorse Jun 24, 2024
4fd2f56
adjust tests to new changes
pedohorse Jun 24, 2024
0ec26c0
NodeSerializerBase INTERFACE CHANGE, simplify deserialization, do not…
pedohorse Jun 25, 2024
aaa029e
DESIGN CHANGE: SchedulerConfigProviderBase to provide structured and …
pedohorse Jun 27, 2024
3dde637
move BaseNodeWithTaskRequirements to node_plugin_base module
pedohorse Jun 27, 2024
6f41ffe
add node parameter evaluation context test
pedohorse Jun 30, 2024
97eee93
adjust base node resource tests for arbitrary resource design
pedohorse Jun 30, 2024
593cb13
introduce arbitrary resources WIP
pedohorse Jun 30, 2024
cc73e4b
allow resource definition overrides for testing
pedohorse Jul 1, 2024
25a92f0
NotPerformed operations not added to undo stack
pedohorse Jul 1, 2024
534ce91
appropriate display for locker/readonly parameters
pedohorse Jul 1, 2024
1ad5969
refactor: plugin loader configuration is supplied from config provider
pedohorse Jul 4, 2024
ca8319d
switch to tree model/view for workers
pedohorse Jul 4, 2024
d867993
refactor pluginloader
pedohorse Jul 6, 2024
6aae08e
fix broken config test
pedohorse Jul 6, 2024
9035e16
add default to resource definition
pedohorse Jul 7, 2024
ea38dd3
check db schema upgrade before dealing with resources
pedohorse Jul 7, 2024
9774c14
default for SHARABLE_COMPUTATIONAL_UNIT - int()
pedohorse Jul 7, 2024
c017272
update requirement-related parameters, assume res0 is cpu, res1 is mem
pedohorse Jul 7, 2024
7ba353f
fix resource test to be async
pedohorse Jul 7, 2024
f89bf4c
add cpu/mem requirement migration logic
pedohorse Jul 7, 2024
d9e87ba
add HardwareResources unittests
pedohorse Jul 7, 2024
ef77d76
cleanup
pedohorse Jul 7, 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
Prev Previous commit
Next Next commit
check db schema upgrade before dealing with resources
  • Loading branch information
pedohorse committed Jul 7, 2024
commit ea38dd31b14a633a4ccec9a62d830ce378ffae86
54 changes: 28 additions & 26 deletions src/lifeblood/scheduler/data_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,34 @@ def __init__(
# ensure database is initialized
with sqlite3.connect(self.__db_path) as con:
con.executescript(sql_init_script)

# upgrade db definitions
with sqlite3.connect(self.__db_path) as con:
con.row_factory = sqlite3.Row
cur = con.execute('SELECT * FROM lifeblood_metadata')
metadata = cur.fetchone() # there should be exactly one single row.
cur.close()
if metadata is None: # if there's no - the DB has not been initialized yet
# we need 64bit signed id to save into db
db_uid = random.getrandbits(64) # this is actual db_uid
db_uid_signed = struct.unpack('>q', struct.pack('>Q', db_uid))[0] # this one goes to db
con.execute('INSERT INTO lifeblood_metadata ("version", "component", "unique_db_id")'
'VALUES (?, ?, ?)', (SCHEDULER_DB_FORMAT_VERSION, 'scheduler', db_uid_signed))
con.commit()
# reget metadata
cur = con.execute('SELECT * FROM lifeblood_metadata')
metadata = cur.fetchone() # there should be exactly one single row.
cur.close()
elif metadata['version'] != SCHEDULER_DB_FORMAT_VERSION:
self.__database_schema_upgrade(con, metadata['version'], SCHEDULER_DB_FORMAT_VERSION) # returns true if commit needed, but we do update next line anyway
con.execute('UPDATE lifeblood_metadata SET "version" = ?', (SCHEDULER_DB_FORMAT_VERSION,))
con.commit()
# reget metadata
cur = con.execute('SELECT * FROM lifeblood_metadata')
metadata = cur.fetchone() # there should be exactly one single row.
cur.close()
self.__db_uid = struct.unpack('>Q', struct.pack('>q', metadata['unique_db_id']))[0] # reinterpret signed as unsigned

# update resource table straight away
# for now the logic is to keep existing columns
with sqlite3.connect(self.__db_path) as con:
Expand Down Expand Up @@ -99,32 +127,6 @@ def __init__(
if need_commit:
con.commit()

with sqlite3.connect(self.__db_path) as con:
con.row_factory = sqlite3.Row
cur = con.execute('SELECT * FROM lifeblood_metadata')
metadata = cur.fetchone() # there should be exactly one single row.
cur.close()
if metadata is None: # if there's no - the DB has not been initialized yet
# we need 64bit signed id to save into db
db_uid = random.getrandbits(64) # this is actual db_uid
db_uid_signed = struct.unpack('>q', struct.pack('>Q', db_uid))[0] # this one goes to db
con.execute('INSERT INTO lifeblood_metadata ("version", "component", "unique_db_id")'
'VALUES (?, ?, ?)', (SCHEDULER_DB_FORMAT_VERSION, 'scheduler', db_uid_signed))
con.commit()
# reget metadata
cur = con.execute('SELECT * FROM lifeblood_metadata')
metadata = cur.fetchone() # there should be exactly one single row.
cur.close()
elif metadata['version'] != SCHEDULER_DB_FORMAT_VERSION:
self.__database_schema_upgrade(con, metadata['version'], SCHEDULER_DB_FORMAT_VERSION) # returns true if commit needed, but we do update next line anyway
con.execute('UPDATE lifeblood_metadata SET "version" = ?', (SCHEDULER_DB_FORMAT_VERSION,))
con.commit()
# reget metadata
cur = con.execute('SELECT * FROM lifeblood_metadata')
metadata = cur.fetchone() # there should be exactly one single row.
cur.close()
self.__db_uid = struct.unpack('>Q', struct.pack('>q', metadata['unique_db_id']))[0] # reinterpret signed as unsigned

async def create_node(self, node_type: str, node_name: str, *, con: Optional[aiosqlite.Connection] = None) -> int:
# TODO: scheduler must use this instead of creating directly
# this should be done as part of a bigger refactoring
Expand Down
Loading