Skip to main content

A parsing module for ALIDA's services

Project description

๐Ÿ“ฆ alidaparse

alidaparse is a Python package for generating CLI arguments required by ALIDA's services. Instead of creating each time an arguments.py, a simple import of alidaparse will do the trick!


๐Ÿš€ Features

  • Automatically generate dataset/model argument for a service
  • Multiple arguments are supported

๐Ÿ“ฅ Installation

Install via pip:

pip install alidaparse

Or install from source:

git https://github.com/JosephMartinelli/alidaparse.git
cd alidaparse
pip install .

๐Ÿงช Usage

Usually a service of the ALIDA's platform needs to declare an arguments.py file in which it defines a series of an arguments it needs in input to work. This file looks something like this:

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--input-dataset", dest="input_dataset", type=str, required=True)
parser.add_argument(
    "--input-dataset.minio_bucket", dest="input_minio_bucket", type=str, required=True
)
...

Those arguments need to be repeated for each input/ouput dataset and model that the service needs to use.

With alidaparse.py you simply import a class that will automatically generate those arguments for you:

# contents of main.py
from alidaparse.input import InDataset

dataset = InDataset.from_cli()

And running main.py will have this effect:

python.exe main.py

usage: main.py [-h] --input-dataset INPUT_DATASET
                    --input-dataset.minio_bucket INPUT_MINIO_BUCKET
                    --input-dataset.minIO_URL INPUT_MINIO_URL
                    --input-dataset.minIO_ACCESS_KEY INPUT_ACCESS_KEY
                    --input-dataset.minIO_SECRET_KEY INPUT_SECRET_KEY
main.py: error: the following arguments are required: --input-dataset, --input-dataset.minio_bucket, --input-dataset.minIO_URL, --input-dataset.minIO_ACCESS_KEY, --input-dataset.minIO_SECRET_KEY

You can also declare multiple arguments by passing an integer to from_cli(n)

# contents of main.py
from alidaparse.input import InDataset

dataset = InDataset.from_cli(n=2)
usage: main.py [-h] --input-dataset-1 INPUT_DATASET_1
--input-dataset-1.minio_bucket INPUT_DATASET_1_MINIO_BUCKET
--input-dataset-1.minIO_URL INPUT_DATASET_1_MINIO_URL
--input-dataset-1.minIO_ACCESS_KEY INPUT_DATASET_1_ACCESS_KEY
--input-dataset-1.minIO_SECRET_KEY INPUT_DATASET_1_SECRET_KEY
--input-dataset-2 INPUT_DATASET_2
--input-dataset-2.minio_bucket INPUT_DATASET_2_MINIO_BUCKET
--input-dataset-2.minIO_URL INPUT_DATASET_2_MINIO_URL
--input-dataset-2.minIO_ACCESS_KEY INPUT_DATASET_2_ACCESS_KEY
--input-dataset-2.minIO_SECRET_KEY INPUT_DATASET_2_SECRET_KEY
main.py: error: the following arguments are required: --input-dataset-1, --input-dataset-1.minio_bucket, 
--input-dataset-1.minIO_URL, --input-dataset-1.minIO_ACCESS_KEY, --input-dataset-1.minIO_SECRET_KEY, 
--input-dataset-2, --input-dataset-2.minio_bucket, --input-dataset-2.minIO_URL, --input-dataset-2.minIO_ACCESS_KEY, 
--input-dataset-2.minIO_SECRET_KEY

alidaparse.py has classes for dealing with input/output datasets, models and custom params. Simply import from alidaparse.input import InDataset,InModel,InParam

๐Ÿ“ Project Structure

alidaparse/
โ”œโ”€โ”€ input/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ input.py  # Contains InDataset,InModel,InParam class
โ”œโ”€โ”€ output/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ output.py  # Contains OutDataset,OutModel class
โ”œโ”€โ”€ test/
โ”‚   โ”œโ”€โ”€ conftest.py # Needed for pytest
โ”‚   โ”œโ”€โ”€ test_input.py
โ”‚   โ””โ”€โ”€ test_output.py
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ setup.py
โ”œโ”€โ”€ pyproject.toml
โ””โ”€โ”€ README.md

๐Ÿ›  Development

To install dependencies:

pip install -r requirements.txt

๐Ÿ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alidaparse-0.1.3.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alidaparse-0.1.3-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file alidaparse-0.1.3.tar.gz.

File metadata

  • Download URL: alidaparse-0.1.3.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.3

File hashes

Hashes for alidaparse-0.1.3.tar.gz
Algorithm Hash digest
SHA256 bd5bcdb5f69cd0874da2b3308499fb58e0f9c271a7fde3bd98a98743e8907dcf
MD5 2d31bdb55238a60437ac46f6f5cf8fdd
BLAKE2b-256 f50dca60414fe552d9bc516d501b760efb2eeecb9246dabdc948e8cb2fe7036a

See more details on using hashes here.

File details

Details for the file alidaparse-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for alidaparse-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a9835cf30390baa2b8380cc42010c83049f005b58f5625a94186beca4917cb53
MD5 69ed8868940936bfda6b2e6ecd47847c
BLAKE2b-256 17c63c52199c51481618db8e5e4c96f89c4e901d97400a76e550e7f35c1262a3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page