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.33-py3-none-any.whl (99.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: viqi_api-0.6.33-py3-none-any.whl
  • Upload date:
  • Size: 99.4 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.33-py3-none-any.whl
Algorithm Hash digest
SHA256 ac0c8d47fc607b153320fd8d56d8f250c005034f68ee4f81c1901b895632ce8e
MD5 5f6dcbc633a0ef98c3daa6b21a3fb4a3
BLAKE2b-256 645fcd47217f7213a5800236eb8213bfbc08b6283cdd311903b37dbaa724c92d

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