-
Notifications
You must be signed in to change notification settings - Fork 20
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
Opensearch #79
Opensearch #79
Conversation
a5b80e6
to
264c01f
Compare
264c01f
to
c6d42fa
Compare
src/diracx/db/__init__.py
Outdated
from .auth.db import AuthDB | ||
from .jobs.db import JobDB, JobLoggingDB | ||
from .sandbox_metadata.db import SandboxMetadataDB | ||
from .sql.auth.db import AuthDB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should that stay here, or do we want to expose to the routers the sql
or os
?
Since we started making the distinction, it's probably worth pursuing so a router would do from diracx.db.sql import AuthDB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I agree, especially as the behavour and API is different in each case.
cf5e33c
to
81270a6
Compare
00ff164
to
4218b9d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To the cost of being a bit more verbose, I would expand everywhere "os" -> "opensearch", for clarity.
Also, as of now you added directories tests/db/opensearch
and src/diracx/db/os
, I would reconcile everything to opensearch
.
from diracx.db.os.utils import BaseOSDB | ||
|
||
for db_name, db_url in BaseOSDB.available_urls().items(): | ||
logger.info("Initialising %s", db_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.info("Initialising %s", db_name) | |
logger.info(f"Initialising {db_name}") |
"HostName": {"type": "keyword"}, | ||
"GridCE": {"type": "keyword"}, | ||
"ModelName": {"type": "keyword"}, | ||
"Status": {"type": "keyword"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Status
should be removed: DIRACGrid/DIRAC#7191
And a few of these should be moved to ElasticPilotParameters: DIRACGrid/DIRAC#7164
Do you want to create this implementation anyway now for testing? In this case put some ToDO notes (the links above would suffice).
for entry_point in select_from_extension(group="diracx.db.os", name=db_name) | ||
] | ||
if not db_classes: | ||
raise NotImplementedError(f"Could not find any matches for {db_name=}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise NotImplementedError(f"Could not find any matches for {db_name=}") | |
raise NotImplementedError(f"Could not find any matches for {db_name}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's the intended behavior
In [1]: a=3
In [2]: f"{a=}"
Out[2]: 'a=3'
try: | ||
conn_kwargs[db_name] = json.loads(os.environ[var_name]) | ||
except Exception: | ||
logger.error("Error loading connection parameters for %s", db_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.error("Error loading connection parameters for %s", db_name) | |
logger.error(f"Error loading connection parameters for {db_name}")``` |
|
||
async def __aenter__(self): | ||
"""This is entered on every request. It does nothing""" | ||
assert self._client is None, "client_context hasn't been entered" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert self._client is None, "client_context hasn't been entered" | |
assert self._client is None, "client_context has not been entered" |
when it is about printing something, I would avoid any possibly-interpreted-as-special characters.
@@ -107,7 +109,7 @@ def available_urls(cls) -> dict[str, str]: | |||
else: | |||
db_urls[db_name] = parse_obj_as(SqlalchemyDsn, db_url) | |||
except Exception: | |||
logger.error("Error loading URL %s for %s", db_name, db_url) | |||
logger.error("Error loading URL for %s", db_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.error("Error loading URL for %s", db_name) | |
logger.error(f"Error loading URL for {db_name}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is intentional, see #35 (comment)
My review was completely ignored? |
Sorry, I did not see it, we were discussing it on a shared screen and I did not refresh the page. |
Example usage
TODOs:
diracx.db
to be split intodiracx.db.os
anddiracx.db.sql
?python -m diracx.db init-os
BaseDB
class with the commonalities betweenBaseSQLDB
andBaseOSDB
?RenameProbably notclient_context
/engine_context
tolifetime_function
?