Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 34 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,43 @@ qualytics --help

### Initializing the Configuration

You can set up your Qualytics URL and token using the `init` command:
You can set up your Qualytics URL and token using the `init` command. This will create configuration in your **home directory** and project structure in your **current working directory**:

```bash
qualytics init --url "https://your-qualytics.qualytics.io/" --token "YOUR_TOKEN_HERE"
**Configuration (in home directory):**
```
~/.qualytics/
└── .env
```

| Option | Type | Description | Default | Required |
|---------|------|-------------------------------------------------------|---------|----------|
| `--url` | TEXT | The URL to be set. Example: https://your-qualytics.qualytics.io/ | None | Yes |
| `--token` | TEXT | The token to be set. | None | Yes |
**Project structure (in current working directory):**
```
./
├── assets/
│ ├── anomalies/
│ ├── check_templates/
│ └── checks/
└── config/
├── connections_example.yml
└── instance.yml
```

You will be prompted to input your URL and token (note that your token won't appear when you type it):

```
Enter your Qualytics URL (e.g., https://your-qualytics.qualytics.io): <your_url>
Enter your Qualytics API token: <your_token>
```

Your credentials are stored in `~/.qualytics/.env` in your home directory, while project files (assets, config) are created in your current working directory.

**Migration Note**: If you were previously using the old `~/.qualytics/config.json` file, simply run the `init` command again. It will automatically:
- Migrate your configuration to the new `.env` format in `~/.qualytics/.env`
- Remove the old JSON config file
- Set up the project structure in your current directory

```bash
qualytics init
```

### Qualytics init help

Expand Down
144 changes: 0 additions & 144 deletions connections.yml.example

This file was deleted.

34 changes: 29 additions & 5 deletions qualytics/cli/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from rich import print
from rich.progress import track

from ..config import BASE_PATH, load_config, is_token_valid
from ..setup import BASE_PATH, get_config, is_token_valid
from ..utils import validate_and_format_url, distinct_file_content, log_error
from ..services.quality_checks import (
get_quality_checks,
Expand Down Expand Up @@ -54,7 +54,13 @@ def checks_export(
"""
Export checks to a file.
"""
config = load_config()
config = get_config()

if not config:
print("[bold red] Error: No configuration found. [/bold red]")
print("[bold yellow] Please run 'qualytics init' to set up your configuration. [/bold yellow]")
raise typer.Exit(code=1)

base_url = validate_and_format_url(config["url"])
token = is_token_valid(config["token"])

Expand Down Expand Up @@ -112,7 +118,13 @@ def check_templates_export(
"""
Export check templates to an enrichment or file.
"""
config = load_config()
config = get_config()

if not config:
print("[bold red] Error: No configuration found. [/bold red]")
print("[bold yellow] Please run 'qualytics init' to set up your configuration. [/bold yellow]")
raise typer.Exit(code=1)

base_url = validate_and_format_url(config["url"])
token = is_token_valid(config["token"])

Expand Down Expand Up @@ -189,7 +201,13 @@ def checks_import(
"""
# Remove brackets if present and split by comma
datastores = [int(x.strip()) for x in datastore.strip("[]").split(",")]
config = load_config()
config = get_config()

if not config:
print("[bold red] Error: No configuration found. [/bold red]")
print("[bold yellow] Please run 'qualytics init' to set up your configuration. [/bold yellow]")
raise typer.Exit(code=1)

base_url = validate_and_format_url(config["url"])
token = is_token_valid(config["token"])
error_log_path = f"/errors-{datetime.now().strftime('%Y-%m-%d')}.log"
Expand Down Expand Up @@ -435,7 +453,13 @@ def check_templates_import(
"""
Import check templates from a file. Only creates new templates, no updates.
"""
config = load_config()
config = get_config()

if not config:
print("[bold red] Error: No configuration found. [/bold red]")
print("[bold yellow] Please run 'qualytics init' to set up your configuration. [/bold yellow]")
raise typer.Exit(code=1)

base_url = validate_and_format_url(config["url"])
token = is_token_valid(config["token"])
error_log_path = f"/errors-{datetime.now().strftime('%Y-%m-%d')}.log"
Expand Down
36 changes: 30 additions & 6 deletions qualytics/cli/datastores.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import typing as t
from rich import print

from ..config import ConfigError, load_config, is_token_valid, CONNECTIONS_PATH
from ..setup import ConfigError, get_config, is_token_valid, CONNECTIONS_PATH
from ..utils import validate_and_format_url, get_connection
from ..services.datastores import (
get_connection_by,
Expand All @@ -17,7 +17,7 @@

# Create Typer instance for datastores
datastore_app = typer.Typer(
name="datastore", help="Create, get, update or delete datastores"
name="datastore", help="Commands for handling datastores"
)


Expand Down Expand Up @@ -78,7 +78,13 @@ def new_datastore(
False, "--dry-run", help="Print payload only; no HTTP"
),
):
config = load_config()
config = get_config()

if not config:
print("[bold red] Error: No configuration found. [/bold red]")
print("[bold yellow] Please run 'qualytics init' to set up your configuration. [/bold yellow]")
raise typer.Exit(code=1)

base_url = base_url = validate_and_format_url(config["url"])
endpoint = "datastores"
url = f"{base_url}{endpoint}"
Expand Down Expand Up @@ -242,7 +248,13 @@ def new_datastore(

@datastore_app.command("list", help="List all datastores")
def list_datastores():
config = load_config()
config = get_config()

if not config:
print("[bold red] Error: No configuration found. [/bold red]")
print("[bold yellow] Please run 'qualytics init' to set up your configuration. [/bold yellow]")
raise typer.Exit(code=1)

base_url = base_url = validate_and_format_url(config["url"])
endpoint = "datastores/listing"
url = f"{base_url}{endpoint}"
Expand Down Expand Up @@ -274,7 +286,13 @@ def get_datastore(
id: int = typer.Option(None, "--id", help="Datastore ID"),
name: str = typer.Option(None, "--name", help="Datastore name"),
):
config = load_config()
config = get_config()

if not config:
print("[bold red] Error: No configuration found. [/bold red]")
print("[bold yellow] Please run 'qualytics init' to set up your configuration. [/bold yellow]")
raise typer.Exit(code=1)

base_url = validate_and_format_url(config["url"])
token = is_token_valid(config["token"])

Expand Down Expand Up @@ -324,7 +342,13 @@ def get_datastore(
def remove_datastore(
id: int = typer.Option(..., "--id", help="Datastore id"),
):
config = load_config()
config = get_config()

if not config:
print("[bold red] Error: No configuration found. [/bold red]")
print("[bold yellow] Please run 'qualytics init' to set up your configuration. [/bold yellow]")
raise typer.Exit(code=1)

base_url = base_url = validate_and_format_url(config["url"])
endpoint = f"datastores/{id}"
url = f"{base_url}{endpoint}"
Expand Down
Loading