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 table format for class object output #249

Open
KSchopmeyer opened this issue Aug 21, 2019 · 13 comments · May be fixed by #752
Open

Add table format for class object output #249

KSchopmeyer opened this issue Aug 21, 2019 · 13 comments · May be fixed by #752

Comments

@KSchopmeyer
Copy link
Contributor

KSchopmeyer commented Aug 21, 2019

DISCUSSION: Looking for ideas here

Today we can output instances and qualifier decls in a table format where the columns are rows but not classes. It might be logical to have a table format for classes.

This could be used to see what properties occur in which classes in a hiearchy.

This has a couple of issues to be resolved:

  1. What would we do with qualifiers since they are a key part of each property and also of the class.

  2. With classes the default value of most properties is Null so it would be an almost empty table. Therefore it might make sense to do something different but I am not sure what yet.

QUESTION: What would goals be for displaying classes in a table format.

  1. Display a single class in something more easily readable on the console than MOF. This could include things like the addition of properties in subclasses, NOTE: From note below that since the class is really fairly complex it will be difficult to do this with a single table, especially on the console.

  2. Display more information on the relations between classes than is in the tree. Note sure this one applies. This could include things like the addition of properties in subclasses, Note that another pr is adding display of the tree-like display of the association relations between classes and instances expanding on the associators and references operations.

  3. Display common or differing characteristics between classes than you can see with things like Enumerate. This could show the changing functionality in a tree of classes, for example.

@KSchopmeyer
Copy link
Contributor Author

KSchopmeyer commented Oct 14, 2019

The class is sufficiently complex that it is probably impossible to express a class or a group of classes as a single table.

DMTF does represent a single class as table in html . The DMTF actually presents the class HTML as a group of items described below some of which are tables.. An example is at: See Example

  1. Title that defines the name and superclass name

  2. Class Description ( the value of the class Description qualifier)

  3. Class hierarchy (effectively pywbemcli class tree diagram showing superclasses

  4. Direct subclasses

  5. Class Qualifiers
    Table with 3 columns
    Name
    DataType
    Value

  6. Class Properties
    Table withmultiple rows
    i. Name
    ii. DataType
    iii. Default Value
    iv. Qualifiers consisting of
    a. Name
    b DataType
    c Value

  7. Inherited Properties
    Table with 3 rows:
    i. Name
    ii. Data Type
    iii. Class Origin (hyperlink to Class Origin)

  8. Association Referneces (If this is an association)
    If this is an association shows table with 3 rows
    Name
    Class Origin
    Reference Class

  9. Class Methods: Consists of two subtables for each method
    Note: There is a line that defines the Method name and return type followed by the
    tables.

i Method Qualifiers
ii. Method Parameters

  1. Inherited Class Methods If there are any)
    Table with 3 rows
    i. Name
    ii. Return Type
    iii. Class Origin (yhperlink)

@KSchopmeyer
Copy link
Contributor Author

What is clear from this is that it is impossible to represent all of the characteristics of a class as a single simple table. It looks like we would need to present this as multiple tables (qualifiers, properties, methods). Note that we do not need to implement the inherited properties/methods as separate tables but with the table for each type.

However, while this works for a single getclass, I am still not sure what we do with enumerate since that would be a series of tables.

@KSchopmeyer
Copy link
Contributor Author

We agreed not to do this in version 0.6.0 but future version beyond that

@KSchopmeyer
Copy link
Contributor Author

I have prototyped this in several ways

  1. Many separate tables - This is a mess

  2. One large table at least per class that would show pretty much everything in the class (subject to what data is available from the command (i.e. no --ico, --lo --iq) options on enumerate. I think this can work but it is clear that it would be significantly more logical to do it with some form of subtable. However, I not that Andy filed an issue on subtables with tabulate over a year ago https://bitbucket.org/astanin/python-tabulate/issues/126/nested-table-support for which there has not been even a response. Also, other possible extensions that might seem logical have been closed by the project lead as will-not-do. Also no commit to the master branch has been made since september 2019 indicating that the maintainer may not actively be maintaining the project.

The questions are:

  1. Is there anything we can do within that project to get some of our proposed changes implemented?

  2. Is their an alternative project. Note I have not found an alternative command line table formatter so far that comes near the capability of tabulate.

  3. What might be other alternatives.

DISCUSSION

@KSchopmeyer
Copy link
Contributor Author

KSchopmeyer commented Jul 31, 2020

We discussed vendoring this tool and will look further into that as an alternative to completing subtabling and creating one table per class (at least) as a table solution.

We also discussed how and what we want to support.

  1. Support the various options like local_only so that only those characteristics requested become part of the table ouput.

  2. We do not want to just show all of the qualifiers. There are many that we should consider unimportant and want to minimize. but not sure exactly what minimize means. We will categorize qualifiers as important/not and modify the display based on that.

@andy-maier
Copy link
Contributor

I'll take on the vendoring part of this issue and have created issue #701 for that.

@andy-maier
Copy link
Contributor

Before we start vendoring tabulate, let's work out what is actually missing as of the latest tabulate version 0.8.7. The things I mentioned in tabulate issue 126 seem to be fixable on our user's end (ie without a change to tabulate).

@andy-maier
Copy link
Contributor

andy-maier commented Jul 31, 2020

BTW, note that the current tabulate repo is on GitHub (https://github.com/astanin/python-tabulate), he moved there in 9/2019, so we should not hope for answers from the issue tracker on BitBucket.

Also, he released a number of versions from the new repo on GitHub, the last release 0.8.7 was in 3/2020. So it is not that bad actually. He just did not care of moving any issues or PRs forward from BitBucket... and since 4/2020 no PRs were merged or issues commented on.

@KSchopmeyer
Copy link
Contributor Author

KSchopmeyer commented Aug 5, 2020

Here is a first example, just to demonstrate that we can capture much of the class info as tables. This is organized as multiple tables rather than a single table, only shows a single table and does a terrible job of showing the qualifiers but it does show subtables within tables and most of the components of the class.

NOTE: This version was put together just to demonstrate an overall concept and how the pieces could look.

 ppp -n mock1 -o table class get CIM_foo
+-------------+--------------+------------------------------------------+
| Classname   | Subclasses   | Qualifiers                               |
|-------------+--------------+------------------------------------------|
| CIM_Foo     | CIM_Foo_sub  | Class Qualifiers                         |
|             | CIM_Foo_sub2 | +------------------+-------------------+ |
|             |              | | Qualifier Name   | Qualifier Value   | |
|             |              | |------------------+-------------------| |
|             |              | | Description      | Simple CIM Class  | |
|             |              | +------------------+-------------------+ |
+-------------+--------------+------------------------------------------+
Properties
+-------------+--------+-------------------------------------------------+
| Property    | Type   | Qualifiers                                      |
| Name        |        |                                                 |
|-------------+--------+-------------------------------------------------|
| InstanceID  | string | +------------------+-----------------------+    |
|             |        | | Qualifier Name   | Qualifier Value       |    |
|             |        | |------------------+-----------------------|    |
|             |        | | Key              | True                  |    |
|             |        | | Description      | This is key property. |    |
|             |        | +------------------+-----------------------+    |
| IntegerProp | uint32 | +------------------+--------------------------+ |
|             |        | | Qualifier Name   | Qualifier Value          | |
|             |        | |------------------+--------------------------| |
|             |        | | Description      | This is Uint32 property. | |
|             |        | +------------------+--------------------------+ |
+-------------+--------+-------------------------------------------------+
Methods
+---------------+----------+--------------------------------------------------------------------------------------------------------------------------------+
| Method        | Return   | Qualifiers and Parameters                                                                                                      |
| Name          | Type     |                                                                                                                                |
|---------------+----------+--------------------------------------------------------------------------------------------------------------------------------|
| Fuzzy         | uint32   | +------------------+-----------------------------------+                                                                       |
|               |          | | Qualifier Name   | Qualifier Value                   |                                                                       |
|               |          | |------------------+-----------------------------------|                                                                       |
|               |          | | Description      | Method with in and out parameters |                                                                       |
|               |          | +------------------+-----------------------------------+                                                                       |
|               |          | +--------------------+-----------+-------------------+-----------------------------------------------------------------------+ |
|               |          | | Parameter          | Type      | Reference Class   | Qualifiers                                                            | |
|               |          | | Name               |           |                   |                                                                       | |
|               |          | |--------------------+-----------+-------------------+-----------------------------------------------------------------------| |
|               |          | | TestInOutParameter | string    |                   | +------------------+------------------------------------------------+ | |
|               |          | |                    |           |                   | | Qualifier Name   | Qualifier Value                                | | |
|               |          | |                    |           |                   | |------------------+------------------------------------------------| | |
|               |          | |                    |           |                   | | IN               | True                                           | | |
|               |          | |                    |           |                   | | OUT              | True                                           | | |
|               |          | |                    |           |                   | | Description      | Define data to be returned in output parameter | | |
|               |          | |                    |           |                   | +------------------+------------------------------------------------+ | |
|               |          | | TestRef            | reference | CIM_Foo           | +------------------+------------------------------+                   | |
|               |          | |                    |           |                   | | Qualifier Name   | Qualifier Value              |                   | |
|               |          | |                    |           |                   | |------------------+------------------------------|                   | |
|               |          | |                    |           |                   | | IN               | True                         |                   | |
|               |          | |                    |           |                   | | OUT              | True                         |                   | |
|               |          | |                    |           |                   | | Description      | Test of ref in/out parameter |                   | |
|               |          | |                    |           |                   | +------------------+------------------------------+                   | |
|               |          | | OutputParam        | string    |                   | +------------------+-------------------------------------+            | |
|               |          | |                    |           |                   | | Qualifier Name   | Qualifier Value                     |            | |
|               |          | |                    |           |                   | |------------------+-------------------------------------|            | |
|               |          | |                    |           |                   | | IN               | False                               |            | |
|               |          | |                    |           |                   | | OUT              | True                                |            | |
|               |          | |                    |           |                   | | Description      | Rtns method name if exists on input |            | |
|               |          | |                    |           |                   | +------------------+-------------------------------------+            | |
|               |          | | OutputRtnValue     | uint32    |                   | +------------------+-----------------------------------+              | |
|               |          | |                    |           |                   | | Qualifier Name   | Qualifier Value                   |              | |
|               |          | |                    |           |                   | |------------------+-----------------------------------|              | |
|               |          | |                    |           |                   | | IN               | True                              |              | |
|               |          | |                    |           |                   | | Description      | Defines return value if provided. |              | |
|               |          | |                    |           |                   | +------------------+-----------------------------------+              | |
|               |          | +--------------------+-----------+-------------------+-----------------------------------------------------------------------+ |
| DeleteNothing | uint32   | +------------------+---------------------------+                                                                               |
|               |          | | Qualifier Name   | Qualifier Value           |                                                                               |
|               |          | |------------------+---------------------------|                                                                               |
|               |          | | Description      | Method with no Parameters |                                                                               |
|               |          | +------------------+---------------------------+                                                                               |
+---------------+----------+--------------------------------------------------------------------------------------------------------------------------------+



COMMENTS:

1. **The subtable is ugly**, since it builds the complete subtable including outside lines within the table. It would be more logical if, at least for some table formats we modified the inner subtable format.

2. The qualifiers subtable is just a display of the components today.  we will clearly have to limit or not display certain qualifiers. We could make each element look like the corresponding mof (name=...) and format each one by folding.  I need to define separate actions for specific qualifiers.

3. While we could build a single table for a class by simply putting a table around each of these component subtables that is probably too simplistic. I need to work more at organizing the data.

4. The Description, while it is a qualifier is really a characteristic of the element itself and an alternate is to show it as a separate column of the element.  The problem is that adds a new column to each element (class, property, etc.) making the table wider whereas today it shows up as in the qualifiers subtable.

5. The current algorithm for selecting column width is very primitive and we need to be more sophisticated.

6. The table for popperties, etc. would probably be significantly wider since I set hide_empty_columnss so that embedded object, reference_class do not show up in this simple example.

@KSchopmeyer
Copy link
Contributor Author

Add html to the list of formats that does not really work. It is not really creating the subtable for some reason.


Classname | Subclasses | Qualifiers
-- | -- | --
CIM_Foo | CIM_Foo_sub CIM_Foo_sub2 | <p>Class Qualifiers</p> <table> <thead> <tr><th>Qualifier Name  </th><th>Qualifier Value  </th></tr> </thead> <tbody> <tr><td>Description     </td><td>Simple CIM Class </td></tr> </tbody> </table>

The html for the first table is as follows:

Classname Subclasses Qualifiers
CIM_Foo CIM_Foo_sub CIM_Foo_sub2 <p>Class Qualifiers</p> <table> <thead> <tr><th>Qualifier Name </th><th>Qualifier Value </th></tr> </thead> <tbody> <tr><td>Description </td><td>Simple CIM Class </td></tr> </tbody> </table>

KSchopmeyer added a commit that referenced this issue Aug 10, 2020
module.

This is first part of adding the code for issue #249, display classes
as tables.  Because the new code is going to significantly increase the
size of the functions associated with displaying objects as tables, it
was logical to move this from _common.py to its own file.

Fixes alse  one pylint issue by changing code

Fixes issue where pylint was reporting possible undefined variable in
pick_one_from_list() when the variable was part of a for statement by
not using that variable and creating a new variable to represent the
same information.

In the process we noted that there was no test for the correct pick of
last item in the list and confirmation that if the next higher number
was picked it treated as invalid a so test was added.
KSchopmeyer added a commit that referenced this issue Aug 10, 2020
module.

This is first part of adding the code for issue #249, display classes
as tables.  Because the new code is going to significantly increase the
size of the functions associated with displaying objects as tables, it
was logical to move this from _common.py to its own file.

Fixes alse  one pylint issue by changing code

Fixes issue where pylint was reporting possible undefined variable in
pick_one_from_list() when the variable was part of a for statement by
not using that variable and creating a new variable to represent the
same information.

In the process we noted that there was no test for the correct pick of
last item in the list and confirmation that if the next higher number
was picked it treated as invalid a so test was added.
andy-maier pushed a commit that referenced this issue Aug 11, 2020
module.

This is first part of adding the code for issue #249, display classes
as tables.  Because the new code is going to significantly increase the
size of the functions associated with displaying objects as tables, it
was logical to move this from _common.py to its own file.

Fixes alse  one pylint issue by changing code

Fixes issue where pylint was reporting possible undefined variable in
pick_one_from_list() when the variable was part of a for statement by
not using that variable and creating a new variable to represent the
same information.

In the process we noted that there was no test for the correct pick of
last item in the list and confirmation that if the next higher number
was picked it treated as invalid a so test was added.
KSchopmeyer added a commit that referenced this issue Sep 1, 2020
module.

This is first part of adding the code for issue #249, display classes
as tables.  Because the new code is going to significantly increase the
size of the functions associated with displaying objects as tables, it
was logical to move this from _common.py to its own file.

Fixes alse  one pylint issue by changing code

Fixes issue where pylint was reporting possible undefined variable in
pick_one_from_list() when the variable was part of a for statement by
not using that variable and creating a new variable to represent the
same information.

In the process we noted that there was no test for the correct pick of
last item in the list and confirmation that if the next higher number
was picked it treated as invalid a so test was added.
KSchopmeyer added a commit that referenced this issue Sep 1, 2020
Adds functions to display class(es) as a table.
@KSchopmeyer KSchopmeyer modified the milestones: 0.8.0, 0.9.0 Sep 16, 2020
@andy-maier andy-maier linked a pull request Oct 6, 2020 that will close this issue
@andy-maier
Copy link
Contributor

DISCUSSION: Discuss proposals and try to limit the options

andy-maier added a commit that referenced this issue Jan 3, 2021
Details:

* In _display_classes_as_table(), replaced the TODO that was in the docstring
  and thus not reported by Pylint, with a TODO as a comment that references
  the existing issue #249 for this TODO.

Signed-off-by: Andreas Maier <[email protected]>
andy-maier added a commit that referenced this issue Jan 5, 2021
Details:

* In _display_classes_as_table(), replaced the TODO that was in the docstring
  and thus not reported by Pylint, with a TODO as a comment that references
  the existing issue #249 for this TODO.

Signed-off-by: Andreas Maier <[email protected]>
@KSchopmeyer KSchopmeyer modified the milestones: 0.9.0, 1.0.0 Mar 17, 2021
@KSchopmeyer
Copy link
Contributor Author

Moved to V 1.0.0

@andy-maier andy-maier modified the milestones: 1.0.0, 1.1.0 Jul 17, 2021
@KSchopmeyer KSchopmeyer modified the milestones: 1.1.0, 1.2.0 Oct 11, 2022
@andy-maier andy-maier modified the milestones: 1.2.0, 1.3.0 Nov 29, 2022
@KSchopmeyer
Copy link
Contributor Author

Move forward to 1.4.0

@KSchopmeyer KSchopmeyer modified the milestones: 1.3.0, 1.4.0 Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants