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

Add support for configuration profiles #395

Merged
merged 9 commits into from
Feb 28, 2024
Merged

Add support for configuration profiles #395

merged 9 commits into from
Feb 28, 2024

Conversation

dlax
Copy link
Member

@dlax dlax commented Aug 23, 2023

This stems from the idea discussed at https://github.com/dalibo/pg_activity/pull/387#issuecomment-1623178466.#396.

$ cat ~/.config/pg_activity/my.conf 
[database]
hidden = true
$ pg_activity --profile my  # will use the file above as configuration

One thing I wonder is whether the option should be named --config <full-path-to-config> or if we should introduce another option later on.


Based on #404

@dlax dlax changed the title Add support for configuration profile Add support for configuration profiles Aug 23, 2023
@dlax dlax marked this pull request as ready for review August 24, 2023 09:49
@dlax dlax requested a review from blogh August 24, 2023 09:49
@blogh
Copy link
Collaborator

blogh commented Aug 25, 2023

From what I understand the configuration we can set in the file relates to the columns of the query display.
@kmoppel-cognite was looking for a way to hide sections of the header (instance, system, workers).

  --no-inst-info        Display instance information in header.
  --no-sys-info         Display system information in header.
  --no-proc-info        Display workers process information in header.

But I guess other options would be nice to have to.

Did I miss something ? (is it something you planned to add afterwards ?)

@dlax
Copy link
Member Author

dlax commented Aug 28, 2023 via email

@kmoppel
Copy link
Contributor

kmoppel commented Aug 29, 2023

Hey, glad to see some progress! Looks promising :) At the same time - do I understand correctly that currently there is still no "infra" for built-in profiles where configs could be read in some fallback mode from some "flags dictionary" in code?

@dlax
Copy link
Member Author

dlax commented Aug 29, 2023

do I understand correctly that currently there is still no "infra" for built-in profiles where configs could be read in some fallback mode from some "flags dictionary" in code?

Sorry, I don't get your question; can you reformulate?

@dlax dlax force-pushed the profile branch 2 times, most recently from 02a00a8 to f7a86c3 Compare February 19, 2024 15:30
@dlax dlax mentioned this pull request Feb 19, 2024
dlax added 9 commits February 21, 2024 08:43
This version has reached its end-of-life last year,
https://peps.python.org/pep-0537/#lifespan.
We use the syntax from PEP 585 and PEP 604 and rely on 'from __future__
import annotations' to modernize the code base.

However, not all generic aliases (e.g. Dict, List) can be replaced
before Python 3.9.
Rephrase their help text and move then to a dedicated options group.
We introduce UIHeader class to hold header-specific options.

Along the way, many names (variables, functions) are changed in order to
make things more explicit.
In the command-line parser, options related to header information have
their default value set to None in order to distinguish when the option
was not specified from when it got, as it would store False then. This
makes it possible to have a precedence of command-line options over the
configuration file (implemented in types.UIHeader.make()).

The validation of configuration options, previously in UISection, is
extracted into a BaseSectionMixin and reused in new HeaderSection.
SectionProxy.get*() would never actually raise NoOptionError because
the 'fallback' argument defaults to None.
Copy link
Collaborator

@blogh blogh left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for adding this !

@dlax dlax merged commit c5ed376 into dalibo:master Feb 28, 2024
3 checks passed
@dlax dlax deleted the profile branch February 28, 2024 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants