Skip to content

Shared libraries

Your company has a common project - reading and writing a database, logging, calling an internal API - and every pipeline or service should call it instead of copying it. archvow only asks one thing: the library is approved - the name you import (ARCH023) and the package in requirements.txt or pyproject.toml (ARCH024). How the library reaches the project is your choice; everything below is optional.

1. Bring the library into the project

Option How Verdict
A. Publish it to your internal package index (Nexus, Artifactory, GitLab package registry) the common project builds a wheel in its CI and publishes it; the project lists acme-common==1.4.0 in its requirements recommended: one pinned version, installed like any package, works the same on a laptop, in CI and on the cluster; nothing else to change
B. Install it from Git, pinned to a tag acme-common @ git+https://gitlab.acme.local/data/common.git@v1.4.0 in the requirements good when there is no package index; still pinned and reviewed
C. Approve it in your company template dependencies: [acme_common] in the template: every project may import it without asking with A or B, when every project uses it
D. Copy its scripts during CI deployment the deploy job copies common/ into the project avoid: no pinned version, tests fail on a developer's machine, code never reviewed in the project
E. A Git submodule common/ inside the repository; allowed_paths [common] in .archvow/project.vow (ARCH015 otherwise) works, but every developer must remember git submodule update

Then approve it once (with A, B, D or E; C already does it) - its import name, and its requirements name too when it is not the same word (acme-common and acme_common are the same for pip):

archvow init my_pipeline --force -a dependencies=acme_common

The approval is a guard change: archvow check --base develop lists it in the merge request and the architects approve it. In mode strict, a package nobody approved fails the build; in mode guided it fails the release gate (check --complete); in mode free it is a warning.

Every reader and writer then asks, as its last question, whether an approved shared library already does its reading or writing (which function, e.g. acme_io.read_jdbc): the decision says it, and the code calls the library instead of rewriting it with Spark.

2. Keep it in one place (optional)

A database library belongs to the I/O layer, never to the business rules. To make that a rule, approve the library for a folder only, in .archvow/project.vow (a guard change, like rules):

dependencies_by_path
  src/my_pipeline/p2_io [acme_common]

An import acme_common anywhere else fails ARCH023 ("may be imported only under src/my_pipeline/p2_io"). A company template can do the same for every project with the same key. Without it, an approved library can be imported anywhere.

3. On a Spark cluster

Code that calls the library only on the driver (a reader that opens a connection, a writer that sends a report) needs nothing more than the installed package on the edge node. Code that calls it inside a UDF runs on the executors: ship it with the job (--py-files with its wheel, or a packed environment with venv-pack, see Packaging for deployment in the project's README).

4. Credentials

archvow never stores secrets. The library reads them at run time from the environment, a secret manager or a keytab, and the spec says where (archvow rule add). The generated ruff.toml refuses a hard-coded password or token, so the Git hook and the CI do too.