Block development toolkit for UP42.
Documentation • UP42.com • Support
Highlights
- Python package with utilities to build blocks in UP42.
- For UP42 partners and customers interested in creating blocks!
- Base classes for data and processing blocks.
- Facilities to easily create tests, ensuring production ready blocks.
Overview
The UP42 blockutils package provides several modules with specific concerns:
- Blocks: Base classes for data and processing blocks.
- Common: Directory and query/parameter input handling.
- Logging: Standard logging facility.
- Data Path: Input and output file handling.
- E2E: Utility class to create end-to-end tests.
- Exceptions: Shared exceptions between blocks.
- Format: Exotic file handling (DIMAP and NETCDF).
- Raster: Raster handling methods.
- Geometry: Generic recurrent geometry operations.
- Windows: Raster windowed read and write helper, useful for large file handling.
- STAC: Handling STAC type queries.
- WMTS: Helper for downloading, processing and merging tiles.
See the full code reference here.
Docker image
In order to make development of blocks easier, we have made available a public blockutils
base image that you can use in your Dockerfile. Check out the
DockerHub page
for the up42/up42-blockutils-py37 image.
Template repositories
For your convenience, we have created two template repositories hosted on GitHub
that include this package and generic make utilities for building and pushing blocks:
Install
The package requires Python > 3.6.
pip install up42-blockutils
Quickstart
The example below shows a minimal processing block that takes a raster file and returns
the raster values to the power of 2. In this example we make use of the logging,
blocks, exceptions, datapath and windows modules.
from pathlib import Path
import rasterio as rio
from geojson import FeatureCollection, Feature
import blockutils
logger = blockutils.logging.get_logger(__name__)
class AProcessingBlock(blockutils.blocks.ProcessingBlock):
def process(self, input_fc: FeatureCollection) -> FeatureCollection:
output_fc = FeatureCollection([])
if not input_fc.features:
raise blockutils.exceptions.UP42Error(
blockutils.exceptions.SupportedErrors.NO_INPUT_ERROR
)
for feat in input_fc["features"]:
logger.info(f"Processing {feat}...")
input_path = Path("/tmp/input/") / Path(blockutils.datapath.get_data_path(feat))
with rio.open(input_path) as src:
src_win = blockutils.windows.WindowsUtil(src)
(
output_name,
output_path,
) = blockutils.datapath.get_output_filename_and_path(
input_path.name, postfix="processed"
)
dst_meta = src.meta.copy()
with rio.open(output_path, "w", **dst_meta) as dst:
for win in src_win.windows_regular():
exp = src.read(window=win) ** 2
dst.write(exp, window=win)
out_feat = Feature(bbox=feat.bbox, geometry=feat.geometry)
out_feat["properties"] = self.get_metadata(feat)
out_feat = blockutils.datapath.set_data_path(out_feat, output_name)
logger.info(f"Processed {out_feat}...")
output_fc.features.append(out_feat)
return output_fc
AProcessingBlock().run()
Support
For any issues or help please contact us via Email support@up42.com.
Metadata
Release files for up42-blockutils 1.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| up42-blockutils-1.2.4.tar.gz | 2.3 MB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| up42_blockutils-1.2.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 2.3 MB
Release files / up42-blockutils-1.2.4.tar.gz
| Download URL | up42-blockutils-1.2.4.tar.gz |
|---|---|
| Size | 2.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1c7f0cdde27486e05b09ea58cbc94b87967d7979b631aaebfc3f01dcfeb34c75
|
|
BLAKE2b-256 checksum How to use checksums |
d9ad574c90354b0a784bc3c90478180fe368c1487dee90da04b013733532935a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.11
|
Release files / up42_blockutils-1.2.4-py3-none-any.whl
| Download URL | up42_blockutils-1.2.4-py3-none-any.whl |
|---|---|
| Size | 33.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4f06baffd564a2e083f2788b3f6f425c27b595764c6f06ddcdaafe213137a311
|
|
BLAKE2b-256 checksum How to use checksums |
de5be9aba06f3e654759f9ae3ce357bc7f97c8c7a779380e625e7268d9e690c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.11
|
Security for up42-blockutils 1.2.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.