semvec/pypi-packages huggingface dataset:
cliyaml 0.1.2
Prototype projects fast with YAML configuration
Requires Python: >=3.12

# CliYaml

Prototype projects fast with YAML configuration, override it with CLI.

The idea of this package is to make building reusable, copiable, and configurable scripts in a very fast and readable way.

For instance, this is especially useful when iterating on `pytorch` model designs and training loops,
using separate scripts that can easily be modified, copied, while keeping a readable YAML & CLI api for running them with various configurations.

Basically:

1. Define a typed default config in a subset of YAML (put paths, devices, epochs, learning rates there...)
2. Define cli subcommands that each refer to a config file using the `@subcommand("file.yaml")` decorator
3. Register subcommands, parse cli args and run the correct subcommands using `initialize()` and `handle()`

## Usage

### YAML subset

This packages relies on YAML for configuration due to its readability, however it only parses a subset of it.
Here is what it looks like.

[`config.yaml`](./tests/config.yaml)

```yaml
# An example configuration

string: "string"
int: 0
float: 0.0

# docstring
docstring: "value"

bool: true

empty: # int

nested:
  one: 1
  two: 2
```

- the top comments are the subcommand's description
- comments before a value are its docstring
- only `true` and `false` are valid booleans
- type hints can be specified for null values with an inline comment
- no lists
- nested values are flattened into a flat python dict, with keys joined by `_`

### CLI API

Define some scripts in separate files, for instance in a `scripts/` folder.

`scripts/main.py`:

```python
from cliyaml import subcommand

# NOTE: multiple different files can be specified to extend the configuration
@subcommand("config.yaml")
def main(**kwargs):
    print("Called with args:", kwargs)
```

In your `main.py`, include the following code:

```python
if __name__ == "__main__":
    import cliyaml

    # Registers subcommands
    # NOTE: you can also register single files
    cliyaml.initialize(None, "scripts/")

    # Parses CLI args and runs commands
    cliyaml.handle()
```

Then, run the following code to use your API:

```bash
python main.py -h
python main.py main -h
python main.py main
```

You can also use `cliyaml.call()` to call a function by giving it `kwargs` directly, it will only pass the correct arguments.
This function also allows you to pass named and list arguments to override the `kwargs`.

## Building

```bash
uv build
```

## Publish

```bash
uv publish
```

## Test

```bash
pytest
```

TODO : more comprehensive tests
pydbro 0.1.16
Python Console Database Browser

[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
```
  ______   _____ ___   ___ ______    ____
  \     `\|  |  |   `\|   |\     `\/'    |
   |   T  |  |  |>    |  <__|   >  |     |
   |   '_,|__   |     |     |     /'  T  |
   |   |  __/  /|  T  |  T  |     `|  :  |
   |   | |     ||  '  |  '  |   |  |     |
   `---' `-----'`-----'-----'---'--`-----'
  %xxxxxxxxx<  CONSOLE PYTHON  >xxxxxxxxx%
  ----------< DATABASE BROWSER >----------
  %xxxxxxxxx< (c) 2022 UNKNOWN >xxxxxxxxx%
  ----------------------------------------```
```
![PYDBRO SCREEN](https://raw.githubusercontent.com/mtatton/pydbro/master/pydbro.png)

 PROGRAM: PYTHON CONSOLE DATABASE BROWSER

```
Help Keyboard Controls:

?   - this help

$   - connection information
j   - move down
k   - move up
h   - move left
l   - move right
L   - shift columns right
H   - shift columns left
0   - go to upper left table corner
G   - go to lower right table corner
n   - next page of records
u   - previous page of records
s   - sort ascending by current column
S   - sort descending by current column
f   - filter (enter claus after where ... )
tab - toggle left / right panel (tables, table content) 
m   - move rows view by 1 page down (tables list)
i   - move rows view by 1 page up (tables list)
r   - reread
e   - edit current cell
d   - delete current row
a   - add new row
X   - reset view (filter, sort) on current table
@   - scroll current row to the top

Note:

Currently the insert, update, delete are only
supported on sqlite and oracle. The other databases
doesn't have rowid pseudo column.

To run this program on Windows You should need
the unofficial curses package for windows.
You can get it here:
Python Extension Packages for Windows - Christoph Gohlke
http://pythonic.zoomquiet.top/data/20101216091618/index.html

To Install use:

$ pip install pydbro

To setup connection you can use the coned program.
To run the coned just use:

$ coned

This will generate json with connectin information
to connect to the mysql, postgres or oracle database.

If You wish to open sqlite file just specify:

$ pydbro -d sqlite file.db

To connect to other databases use:

$ pydbro -d [mysql|postgres|oracle]

and connect according to connection json.

To connect to the mysql|postgres|oracle database You
would need following packages:

for MySQL:    $ pip install mysql-connector 
for Oracle:   $ pip install cx_Oracle 
for Postgres: $ pip install psycopg2-binary

To develop or use the git repository version use:

$ python3 setup.py develop

To both use the commands and run.sh

Special Thanks goes to:

Lawrence Manuel aka Smooth for the Logo

```