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 property aliasing to Python properties #912

Open
xmkg opened this issue Jul 2, 2024 · 0 comments
Open

Add property aliasing to Python properties #912

xmkg opened this issue Jul 2, 2024 · 0 comments

Comments

@xmkg
Copy link
Contributor

xmkg commented Jul 2, 2024

Currently, property names are long because they must be the full import path to the property, e.g.:

@hotsos.core.plugins.kernel.memory.MemInfo.mem_avail_to_mem_total_percentage

The given example property is implemented in the MemInfo class as follows:

hotsos/core/plugins/kernel/memory/MemInfo.py:

class MemInfo(_BaseProcKeyValue):
    # /* .... */
    @property
    def mem_avail_to_mem_total_percentage(self):
        return round((self.MemAvailable * 100) / self.MemTotal)

We could allow aliasing such properties to a shorter, more comprehensible name with a decorator, e.g.:

hotsos/core/plugins/kernel/memory/MemInfo.py:

class MemInfo(_BaseProcKeyValue):
    # /* .... */
    @property
    @alias('kernel.mem.avail_to_total_pct')
    def mem_avail_to_mem_total_percentage(self):
        return round((self.MemAvailable * 100) / self.MemTotal)

... so we can refer to it in YAML files like:

@kernel.mem.avail_to_total_pct
xmkg added a commit to xmkg/hotsos that referenced this issue Jul 5, 2024
at the moment, scenarios are using the long import paths in order to
reference to a Python property. this feature allows assigning an alias
to a Python class or variable in order to make using plugin property
interfaces easier.

Added aliases to the plugins.
Updated existing scenarios to use aliases.

Fixes canonical#912

Signed-off-by: Mustafa Kemal Gilor <[email protected]>
xmkg added a commit to xmkg/hotsos that referenced this issue Jul 7, 2024
at the moment, scenarios are using the long import paths in order to
reference to a Python property. this feature allows assigning an alias
to a Python class or variable in order to make using plugin property
interfaces easier.

Added aliases to the plugins.
Updated existing scenarios to use aliases.

Fixes canonical#912

Signed-off-by: Mustafa Kemal Gilor <[email protected]>
xmkg added a commit to xmkg/hotsos that referenced this issue Jul 7, 2024
at the moment, scenarios are using the long import paths in order to
reference to a Python property. this feature allows assigning an alias
to a Python class or variable in order to make using plugin property
interfaces easier.

Added aliases to the plugins.
Updated existing scenarios to use aliases.

Fixes canonical#912

Signed-off-by: Mustafa Kemal Gilor <[email protected]>
xmkg added a commit to xmkg/hotsos that referenced this issue Jul 12, 2024
at the moment, scenarios are using the long import paths in order to
reference to a Python property. this feature allows assigning an alias
to a Python class or variable in order to make using plugin property
interfaces easier.

Added aliases to the plugins.
Updated existing scenarios to use aliases.

Fixes canonical#912

Signed-off-by: Mustafa Kemal Gilor <[email protected]>
xmkg added a commit to xmkg/hotsos that referenced this issue Jul 12, 2024
at the moment, scenarios are using the long import paths in order to
reference to a Python property. this feature allows assigning an alias
to a Python class or variable in order to make using plugin property
interfaces easier.

Added aliases to the plugins.
Updated existing scenarios to use aliases.

Fixes canonical#912

Signed-off-by: Mustafa Kemal Gilor <[email protected]>
xmkg added a commit to xmkg/hotsos that referenced this issue Jul 18, 2024
at the moment, scenarios are using the long import paths in order to
reference to a Python property. this feature allows assigning an alias
to a Python class or variable in order to make using plugin property
interfaces easier.

Added aliases to the plugins.
Updated existing scenarios to use aliases.

Fixes canonical#912

Signed-off-by: Mustafa Kemal Gilor <[email protected]>
xmkg added a commit to xmkg/hotsos that referenced this issue Jul 30, 2024
at the moment, scenarios are using the long import paths in order to
reference to a Python property. this feature allows assigning an alias
to a Python class or variable in order to make using plugin property
interfaces easier.

Added aliases to the plugins.
Updated existing scenarios to use aliases.

Fixes canonical#912

Signed-off-by: Mustafa Kemal Gilor <[email protected]>
xmkg added a commit to xmkg/hotsos that referenced this issue Jul 30, 2024
at the moment, scenarios are using the long import paths in order to
reference to a Python property. this feature allows assigning an alias
to a Python class or variable in order to make using plugin property
interfaces easier.

Added aliases to the plugins.
Updated existing scenarios to use aliases.
Added unit tests for the aliasing code.
Updated the docs.

Fixes canonical#912

Signed-off-by: Mustafa Kemal Gilor <[email protected]>
xmkg added a commit to xmkg/hotsos that referenced this issue Aug 1, 2024
at the moment, scenarios are using the long import paths in order to
reference to a Python property. this feature allows assigning an alias
to a Python class or variable in order to make using plugin property
interfaces easier.

Added aliases to the plugins.
Updated existing scenarios to use aliases.
Added unit tests for the aliasing code.
Updated the docs.

Fixes canonical#912

Signed-off-by: Mustafa Kemal Gilor <[email protected]>
xmkg added a commit to xmkg/hotsos that referenced this issue Aug 16, 2024
at the moment, scenarios are using the long import paths in order to
reference to a Python property. this feature allows assigning an alias
to a Python class or variable in order to make using plugin property
interfaces easier.

Added aliases to the plugins.
Updated existing scenarios to use aliases.
Added unit tests for the aliasing code.
Updated the docs.

Fixes canonical#912

Signed-off-by: Mustafa Kemal Gilor <[email protected]>
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 a pull request may close this issue.

1 participant