Helpers for Cosmos DB and Azure Storage operations
Project description
hel-elmuro
Python helpers for the ElMuro transportation analytics platform.
Features
- Persist pandas DataFrames into Azure Cosmos DB containers.
- Perform common Azure Blob Storage operations (count, copy, delete, move).
Installation
pip install hel-elmuro
Quick Start
from hel_elmuro import CosmosManager, FileManager
cosmos = CosmosManager(
endpoint="https://<account>.documents.azure.com:443/",
key="<cosmos-key>",
database_name="elmuro",
container_name="drivers",
)
inserted = cosmos.save_dataframe(df, partition_key_column="driver_id")
files = FileManager(
connection_string="<storage-connection-string>",
container_name="dap0gescab0con",
)
files.move("bronze/file.json", "silver/file.json")
File Organization
- Is not defined by the workspace convention.
- The organization is defined by the build process defined in the
/pyproject.tomlfile; by default the build artifacts source code is collected fromsrc/hel_elmuro. - All library modules should live under
src/hel_elmuroso editable installs and wheels include the package correctly.
Development & Testing
- All examples assume Visual Studio Code and a power shell terminal environment.
- Install the package in editable mode for iterative work:
pip3 install -e "hel_elmuro_pkg[dev]". - Development dependencies (pytest, black, flake8) are defined in
pyproject.tomlunder thedevextra. - Based on the pytest python module. defined in dev depedencies in the .toml file of the proyect. Test is in the tests folder and it will execute every function declared in that files. Organization of the files is something reletaed with the workspace conventions to organize per file the different unit testing of specific objects. (Modules/class in this cases).
Run the suite from the project repository root so editable installs resolve correctly:
python3 -m pytest
When you need to run tests from the package directory with explicit logging parameters:
cd hel_elmuro_pkg
python3 -m pytest --log-cli-level=INFO -s
Release (PyPI)
These steps publish the hel-elmuro package only; other projects in the workspace have their own workflows.
- Bump the
project.versionvalue inhel_elmuro_pkg/pyproject.tomlto the desired semantic version (MAJOR.MINOR.PATCH), and update any information there. - Ensure the workspace has
buildandtwineinstalled (pip3 install --upgrade build twine). - Remember to solve pendent action in the git to create the tag properly and get the info from the git properly.
- From the repository root execute the
hel-elmurorelease helper athel_elmuro_pkg/scripts/publish_release.py(tests are executed again as part of this step):python3 hel_elmuro_pkg/scripts/publish_release.py- The script reads the package name and version from
pyproject.toml. - It verifies the working tree is clean, checks the declared version is newer than the latest git tag and PyPI release, and runs
python -m pytestbefore proceeding. - Packaging uses
python -m buildto create both the source archive (dist/<name>-<version>.tar.gz) and wheel (dist/<name>-<version>-py3-none-any.whl). - Publishing uses
python -m twine upload dist/*, which prompts for the PyPI API token and pushes the artifacts. - A git tag named
hel-elmuro-v<version>is created and pushed so releases stay scoped to the package. - Build metadata (
hel_elmuro_pkg/dist/andhel_elmuro_pkg/src/hel_elmuro.egg-info/) is regenerated every release and stays ignored by Git via.gitignore.
- The script reads the package name and version from
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 hel_elmuro-0.4.0.tar.gz.
File metadata
- Download URL: hel_elmuro-0.4.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac3f85856668c8dda85e3e0bd0c282a26e171bde9c473d1e4ed005a165e729dd
|
|
| MD5 |
e065c940785cde1e00c06f6348b773a8
|
|
| BLAKE2b-256 |
b55a778b9fd12bce904bc8074c5cca254f22d60c5f87327fe028108001f95ac8
|
File details
Details for the file hel_elmuro-0.4.0-py3-none-any.whl.
File metadata
- Download URL: hel_elmuro-0.4.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b27dede1026b880a93e6b971778cc70ca7abb93a90f325322d8a0136a86f347
|
|
| MD5 |
3fc6ec4100a2691e6e9f8b18b866967c
|
|
| BLAKE2b-256 |
19d804fa3175448371d3af03550b6b6fc65a92285004253dccd82255a211f29a
|