Skip to content

Commit

Permalink
move database call out of spalloc
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Sep 20, 2023
1 parent e02ab1b commit 05e8126
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
9 changes: 3 additions & 6 deletions spinnman/spalloc/spalloc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,8 @@ def __init__(self, session, job_handle):
self.__proxy_thread = None
self.__proxy_ping = None

@overrides(SpallocJob._write_session_credentials_to_db)
def _write_session_credentials_to_db(self, cur):
@overrides(SpallocJob.get_session_credentials_for_db)
def get_session_credentials_for_db(self):
config = {}
config["SPALLOC", "service uri"] = self._service_url
config["SPALLOC", "job uri"] = self._url
Expand All @@ -471,10 +471,7 @@ def _write_session_credentials_to_db(self, cur):
# We never write the auth headers themselves; we just extend the
# session
del headers["Authorization"]
cur.executemany("""
INSERT INTO proxy_configuration(kind, name, value)
VALUES(?, ?, ?)
""", [(k1, k2, v) for (k1, k2), v in config.items()])
return config

@overrides(SpallocJob.get_state)
def get_state(self):
Expand Down
8 changes: 2 additions & 6 deletions spinnman/spalloc/spalloc_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,13 @@ def where_is_machine(self, x: int, y: int) -> Tuple[int, int, int]:
"""

@abstractmethod
def _write_session_credentials_to_db(self, cur: Cursor):
def get_session_credentials_for_db(self):
"""
Write the session credentials for the job to the database accessed by
the given cursor.
Get the session credentials for the job to be written into a database
.. note::
May assume that there is a ``proxy_configuration`` table with
``kind``, ``name`` and ``value`` columns.
:param ~sqlite3.Cursor cur:
The open cursor to the database.
"""

def __enter__(self):
Expand Down

0 comments on commit 05e8126

Please sign in to comment.