Official Python SDK for the Vilvik genetic-algorithm cloud API.
Project description
vilvik
Official Python SDK for Vilvik — a cloud platform that runs Genetic Algorithm (PyGAD) workloads with a REST API, scoped keys, and webhook delivery.
pip install vilvik
Quick start
import vilvik
client = vilvik.Client(api_key="vlk_live_…")
submission = client.submissions.create(
fitness_func="""
def fitness_func(ga_instance, solution, idx):
return -sum(s * s for s in solution)
""",
num_genes=5,
num_generations=100,
sol_per_pop=50,
name="quadratic-minimisation",
)
print(submission.id, submission.status) # "abc123…", "queued"
result = client.results.wait_for(submission.id, timeout=300)
print(result.best_fitness, result.best_solution)
The run() one-liner
For scripts and notebook cells, vilvik.run(...) packages create-and-wait
into a context manager that also cancels the run if you exit the block
early:
import vilvik
fn = """
def fitness_func(ga_instance, solution, idx):
return -sum(s * s for s in solution)
"""
with vilvik.run(fitness_func=fn, num_genes=5, num_generations=50) as result:
print(result.best_fitness)
The API key is read from VILVIK_API_KEY if you do not pass it
explicitly.
Listing and pagination
The list endpoints return a Page whose items are typed dataclasses; for
walking everything use iter_all:
page = client.submissions.list(limit=25)
for sub in page:
print(sub.id, sub.status, sub.name)
# All submissions, transparently following the cursor:
for sub in client.submissions.iter_all():
...
Branching a finished run
B7 — branching run-graph is exposed via Results.continue_run. Each
call creates a child submission whose parent_submission is the result
you forked from. Pass any GA parameter you want to override:
parent = client.results.get(result_id)
variant_a = client.results.continue_run(parent.id, mutation_probability=0.10)
variant_b = client.results.continue_run(parent.id, sol_per_pop=100)
The Vilvik dashboard renders the resulting lineage as an interactive tree on the result page.
Errors
Every SDK error inherits from vilvik.VilvikError. Subclasses let you
catch specific failure modes:
try:
client.submissions.get("does-not-exist")
except vilvik.NotFoundError as e:
print("Not found:", e.request_id)
except vilvik.RateLimitError as e:
print("Slow down, retry after", e.retry_after, "seconds")
except vilvik.AuthenticationError:
print("Check your API key and scopes")
except vilvik.VilvikError:
print("Something else went wrong")
Configuration
| Argument | Default | Notes |
|---|---|---|
api_key |
os.environ["VILVIK_API_KEY"] |
Required. Bearer token created in the dashboard. |
base_url |
https://vilvik.com/api/v1 |
Override for staging or self-hosted instances. |
timeout |
60.0 seconds |
Per-HTTP-request timeout. |
max_retries |
2 |
Idempotent (GET / HEAD) retries on network errors. |
Development
pip install -e ".[dev]"
pytest
License
MIT.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vilvik-0.2.0.tar.gz.
File metadata
- Download URL: vilvik-0.2.0.tar.gz
- Upload date:
- Size: 24.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38fe31486eac9277108a99cc3a7553c1ee81d6bb0a484d81e2858a88c588d8cd
|
|
| MD5 |
c11852c5a7a57119de59ae6624b6c8e2
|
|
| BLAKE2b-256 |
6f70261e78ffc8f1f25ae06af0af54b92c9dc54aedb32fcccb3c88477d1c1b64
|
File details
Details for the file vilvik-0.2.0-py3-none-any.whl.
File metadata
- Download URL: vilvik-0.2.0-py3-none-any.whl
- Upload date:
- Size: 21.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c49b88798884b56f8d310ebaee98246ff0998c9af5c642169b150ef722eb92d
|
|
| MD5 |
dc248029e06c7f1dc550404d26a65452
|
|
| BLAKE2b-256 |
65d4544465ba9ba7221cb4ae4c884fc3ebbcc921d5e608d8b92f692f906543ce
|