sisl icon indicating copy to clipboard operation
sisl copied to clipboard

First try at automated data CLI

Open pfebrer opened this issue 8 months ago • 4 comments

As discussed with Nick, this is a minimal first attempt for the automatic generation of a CLI to postprocess data.

The aim is to organize things in a way that new methods to generate data can be simply registered to data classes and automatically added to the CLI, without needing to maintain CLI options all across sisl.

The automatic generation of a CLI requires of course some boilerplate code, but the amount of boilerplate code is almost constant when we add new functionality.

The approach taken:

  • Created data classes in sisl.data that should help gathering all the possible ways in which the same data can be generated. For now I only implemented DOSData.
  • Then functions to create that data should be registered. For now I have only registered the function that creates DOSData from eigSileSiesta. This functions should be type annotated to be automatically supported by the CLI.
  • The CLI is created independently in sisl.cli.sdata. For now it can be ran with python -m sisl.cli.sdata. That file is hyper documented, and there I explain all the parts that play a role in generating the CLI.

This standarization should not only help to create sisl's CLI but also facilitate the creation of other interfaces to sisl down the line (including the GUI).

To use it, for now, you need to install nodify's dev version, click and rich_click:

pip install [email protected]:pfebrer/nodify.git click rich_click 

The CLI can work in two ways:

Specify the type of data that you want and how to get it.

Main: Screenshot from 2024-06-26 23-21-16

DOS data: Screenshot from 2024-06-26 23-20-46

DOS data from the EIG file: Screenshot from 2024-06-26 23-20-56

Pass a file, then only specify which data you want to get

Main: Screenshot from 2024-06-26 23-24-25

DOS data: Screenshot from 2024-06-26 23-25-38

pfebrer avatar Jun 26 '24 21:06 pfebrer