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

Rework database modules and class names #3191

Merged
merged 5 commits into from
Feb 17, 2023

Conversation

portante
Copy link
Member

@portante portante commented Jan 18, 2023

Commit message for this PR:

Rework database modules and class names

The main goal for this work is consistency in naming surrounding the
database models.

Most of the code refers to "auth tokens" in various contexts. As such,
"active token(s)" names are renamed to "auth token(s)".

Related to that, we update other database modules so that they follow
the same pattern of singluar module name and plural table names.  The
plural table names are more natural when constructing SQL queries.  We
also change the database module model names to follow their table names.

One notable change is that the `database.model.server_configs` module
has been renamed to `database.model.server_settings`, with the ORM class
name renamed from `ServerConfig` to `ServerSetting`.

We are making both changes in this commit so that we can provide one
database migration for the changes.

This is work pulled from a series of commits in PR #3114:

The work is not a simple repeat of those commits but a more thorough consideration of them.

@portante portante added enhancement Server API Of and relating to application programming interfaces to services and functions Database labels Jan 18, 2023
@portante portante added this to the v0.72 milestone Jan 18, 2023
@portante portante self-assigned this Jan 18, 2023
Copy link
Member

@dbutenhof dbutenhof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only skimmed really quickly, but a few offhand comments...

lib/pbench/server/database/models/datasets.py Outdated Show resolved Hide resolved
lib/pbench/server/database/models/server_configs.py Outdated Show resolved Hide resolved
lib/pbench/server/database/models/auth_tokens.py Outdated Show resolved Hide resolved
webbnh
webbnh previously approved these changes Jan 18, 2023
Copy link
Member

@webbnh webbnh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK to me, for the most part. I would prefer that "metadata" and "server_config" not acquire trailing s's, and I don't think we need the comments justifying the plural-ness of the table names (and I have a suggestion for ridding us of a Black-ism), but nothing I would stop the merge for.

lib/pbench/server/database/models/datasets.py Outdated Show resolved Hide resolved
lib/pbench/server/database/models/server_configs.py Outdated Show resolved Hide resolved
lib/pbench/server/api/resources/__init__.py Outdated Show resolved Hide resolved
lib/pbench/server/database/models/auth_tokens.py Outdated Show resolved Hide resolved
lib/pbench/server/database/models/auth_tokens.py Outdated Show resolved Hide resolved
lib/pbench/server/database/models/users.py Show resolved Hide resolved
@portante
Copy link
Member Author

Now, just so you know, I did not request review on this PR yet. I still have to create a migration and do some additional verification.

@webbnh
Copy link
Member

webbnh commented Jan 18, 2023

I did not request review on this PR yet. I still have to create a migration and do some additional verification.

Sorry...the description seemed to imply that we could review this once the previous PR had landed...which is has. 🙂

As long as you don't edit the existing commits, it won't be a problem.... 😉

@portante
Copy link
Member Author

The CI functional tests failed due to #3209 (see PR #3210 for a possible fix). Retrying in the hopes they pass.

@portante portante force-pushed the PBENCH-1052 branch 2 times, most recently from 32f6b06 to 7af9dae Compare January 30, 2023 20:48
@portante portante force-pushed the PBENCH-1052 branch 4 times, most recently from b8a1a45 to 1e2d0e1 Compare February 5, 2023 15:04
@portante portante force-pushed the PBENCH-1052 branch 4 times, most recently from d11537e to 2181b2d Compare February 9, 2023 18:11
@portante portante force-pushed the PBENCH-1052 branch 2 times, most recently from 7031480 to dfb770b Compare February 14, 2023 14:26
@portante portante marked this pull request as ready for review February 14, 2023 14:27
@portante portante requested review from dbutenhof and webbnh February 14, 2023 14:27
dbutenhof
dbutenhof previously approved these changes Feb 14, 2023
Copy link
Member

@dbutenhof dbutenhof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No major issues; a few comments. One of which you've already resolved in the middle of my review. Ha.

lib/pbench/server/database/models/auth_tokens.py Outdated Show resolved Hide resolved
lib/pbench/server/database/models/server_settings.py Outdated Show resolved Hide resolved
@portante
Copy link
Member Author

Flakey agent legacy test killed the CI job.

webbnh
webbnh previously approved these changes Feb 14, 2023
Copy link
Member

@webbnh webbnh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow. That was a lot of change. And, I'm not sure that we got much value out of it.

I have two concerns, both centering on items whose names differ only in the trailing s. Unfortunately, I don't have a good solution for resolving ServerSetting vs. ServerSettings (short of renaming one of them back to "config" or similar, although we could change the latter to ServerSettingAPI or ServerSettingResource). However, in the case of the other, auth_tokens, I think maybe the rename was incomplete -- naming both of them consistently would remove the hazard.

Other than those, I just hit a few nits.

docs/API/V1/server_settings.md Show resolved Hide resolved
lib/pbench/server/api/resources/server_settings.py Outdated Show resolved Hide resolved
lib/pbench/server/database/models/server_settings.py Outdated Show resolved Hide resolved
lib/pbench/server/database/models/users.py Show resolved Hide resolved
lib/pbench/server/database/models/server_settings.py Outdated Show resolved Hide resolved
lib/pbench/server/database/models/server_settings.py Outdated Show resolved Hide resolved
The main goal for this work is consistency in naming surrounding the
database models.

Most of the code refers to "auth tokens" in various contexts. As such,
"active token(s)" names are renamed to "auth token(s)".

Related to that, we update other database modules so that they follow
the same pattern of singluar module name and plural table names.  The
plural table names are more natural when constructing SQL queries.  We
also change the database module model names to follow their table names.

One notable change is that the `database.model.server_configs` module
has been renamed to `database.model.server_settings`, with the ORM class
name renamed from `ServerConfig` to `ServerSetting`.

We are making both changes in this commit so that we can provide one
database migration for the changes.
@portante portante requested review from webbnh and dbutenhof February 15, 2023 16:05
@portante portante merged commit 82b2ad1 into distributed-system-analysis:main Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Of and relating to application programming interfaces to services and functions Database enhancement Server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants