Skip to main content

ViQi Python API

Project description

ViQi API

Low level interface to ViQi services

Install

pip install viqi-api

Configuration

For command line tools create ~/.config/viqi/profiles or `~/config/viqi/profiles`` (windows) with the following

[default]
host=https://science.viqiai.cloud
user=myuser
password=mysecret

[science-user2]
host=https://science.viqiai.cloud
user=myuser2
password=mysecret2

# Admin can switch to another user
[science-secret-user]
host=https://science.viqiai.cloud
user=admin@viqi.org
password=admin_secret
alias=secret-user@viqi.org

Documentation

Usage & Initialization

The viqi_session helper provides a flexible way to initialize a session, whether from command line arguments, configuration files, or direct parameters in Python.

1. From Command Line Arguments (Scripts)

When used in a script without arguments, viqi_session() automatically parses sys.argv. This is the standard way to write scripts that can be configured via flags or config files.

myscript.py:

from vqapi import viqi_session
session = viqi_session()

if session:
    # Session is ready and connected
    print(f"Connected to {session.bqServer} as {session.user}")

    # Access services
    meta = session.service("meta")
    # ...

Run it:

# Using explicit credentials
python myscript.py --host https://science.viqiai.cloud --user myuser --password mysecret

# Using a profile defined in ~/.config/viqi/profiles
python myscript.py --profile default

2. From Python Parameters (Interactive/Library)

You can pass arguments directly as keyword arguments. This is useful for interactive sessions (like IPython/Jupyter) or when embedding the library.

from vqapi import viqi_session

# Using a profile defined in ~/.config/viqi/profiles
session = viqi_session(profile="science-user2")

# Using explicit credentials
session = viqi_session(
    host="https://science.viqiai.cloud",
    user="myuser",
    password="mysecret"
)

# Using an auth token
session = viqi_session(
    host="https://science.viqiai.cloud",
    authtoken="YOUR_AUTH_TOKEN"
)

3. Simulating Command Line Arguments

You can pass a list of strings to args to simulate command line input.

session = viqi_session(args=["--host", "https://science.viqiai.cloud", "--user", "admin", "--password", "secret"])

4. Custom Argument Parser

If your script requires its own custom arguments, you can extend the standard ViQi parser.

import argparse
from vqapi import viqi_session, viqi_argument_parser

# 1. Start with the standard ViQi parser
parser = viqi_argument_parser()

# 2. Add your custom arguments
parser.add_argument("--dataset-id", required=True, help="ID of dataset to process")

# 3. Parse args (handles both ViQi args and custom args)
args = parser.parse_args()

# 4. Initialize session using the parsed arguments
session = viqi_session(args=args)

# 5. Use your custom argument
print(f"Processing dataset: {args.dataset_id}")

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

viqi_api-0.6.24-py3-none-any.whl (98.5 kB view details)

Uploaded Python 3

File details

Details for the file viqi_api-0.6.24-py3-none-any.whl.

File metadata

  • Download URL: viqi_api-0.6.24-py3-none-any.whl
  • Upload date:
  • Size: 98.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for viqi_api-0.6.24-py3-none-any.whl
Algorithm Hash digest
SHA256 f3465d60f5555e8c47383e5ec14463f4a35a31d8cfb65a70197f0c2102fa39b5
MD5 09c4923ef7667f19122693e0e942bec9
BLAKE2b-256 607c1f6960da4e8aeb949f8818fb0429de84db7dceeb1c3b0c74c3a4ecdba38a

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