Processors#
The hastegeo.core.processors package contains the business logic layer for all HASTE operations. Processors coordinate between data layers, runners, and utilities to implement the platform’s core functionality.
Imagery (hastegeo.core.processors.imagery)#
Handles satellite imagery download, preprocessing, and Cloud Optimized GeoTIFF creation.
ImageryPreProcessor— Queue imagery for async processingImageryPostProcessor— Execute the full imagery preprocessing pipeline (download, mosaic, COG creation, tiling)ImageryLogRecord— Timestamped log record for imagery processing
- class hastegeo.core.processors.imagery.ImageryLogRecord(timestamp, message)[source]#
Bases:
NamedTupleNamed tuple representing a log record for imagery processing operations.
This structure captures timestamped log messages generated during imagery preprocessing workflows, providing structured logging for debugging and progress tracking.
Example
```python log_record = ImageryLogRecord(
timestamp=”2023-08-01T12:00:00Z”, message=”Starting imagery preprocessing for layer img_123”
) print(log_record) # “2023-08-01T12:00:00Z: Starting imagery preprocessing…” ```
- class hastegeo.core.processors.imagery.ImageryPostProcessor(image_data, config=None)[source]#
Bases:
object
- class hastegeo.core.processors.imagery.ImageryPreProcessor(image_data, config=None)[source]#
Bases:
objectProcessor for handling satellite and aerial imagery preprocessing workflows.
This class manages the complete imagery preprocessing pipeline including download, validation, mosaic creation, and Cloud Optimized GeoTIFF (COG) generation. It integrates with Azure Batch services for scalable processing and Azure Queue Storage for asynchronous job management.
The processor handles both pre-event and post-event imagery for change detection and damage assessment workflows, supporting multiple imagery sources and formats.
- Parameters:
image_data (ImageLayer) – Image layer model containing imagery metadata and URLs
config (Config, optional) – Configuration object with environment settings. Defaults to None, which creates a new Config instance.
- image_data#
The image layer being processed
- Type:
- queue#
Queue handler for asynchronous job management
- Type:
- Raises:
ValueError – If image_data is not a valid ImageLayer instance
Example
```python # Create image layer with pre and post event imagery image_layer = ImageLayer(
imageLayerId=”layer_123”, projectId=”proj_456”, preEventImageryUrls=[”https://storage/pre_event.tif”], postEventImageryUrls=[”https://storage/post_event.tif”]
)
# Initialize processor and queue for processing processor = ImageryPreProcessor(image_layer) processor.queue_for_processing() ```
Note
The processor supports various imagery sources including Sentinel-2, Landsat, WorldView, and other satellite/aerial imagery formats. All processing operations are designed to handle large-scale imagery datasets efficiently through cloud-based batch processing.
- queue_for_processing()[source]#
Queue the imagery layer for asynchronous preprocessing.
This method prepares the image layer for processing by setting initial status values and sending the layer data to the Azure Queue for asynchronous processing by background workers.
The method sets up progress tracking with 4 total processing steps: 1. Download and validation of imagery files 2. Mosaic creation for multi-file imagery 3. Cloud Optimized GeoTIFF (COG) generation 4. Metadata updates and finalization
Updates the image layer status to PENDING and resets progress indicators before queuing the processing job.
- Returns:
The updated image layer with processing status set to PENDING
- Return type:
Example
`python processor = ImageryPreProcessor(image_layer) updated_layer = processor.queue_for_processing() print(f"Layer {updated_layer.imageLayerId} queued with status: {updated_layer.status}") `Note
The actual processing is handled asynchronously by Azure Queue consumers. This method only queues the job and updates initial status.
- hastegeo.core.processors.imagery.save_imagery_layer(image_layer, config=None, prepare_footprints=False)[source]#
Persist imagery/label work without overwriting footprint job state.
Only the final successful save may publish footprint work. Nothing in the imagery handler saves a stale footprint snapshot after publication. Other imagery saves (including error handling/redelivery) also exclude footprint-owned fields, using MetadataProcessor’s top-level merge.
Training (hastegeo.core.processors.train)#
ML model training workflow management.
BaseTrainProcessor— Base class for training operationsTrainPreprocessor— Queue models for training (prepares experiment config)TrainPostprocessor— Execute and monitor training jobs on Azure Batch
- class hastegeo.core.processors.train.BaseTrainProcessor(model, image_layer, config=None)[source]#
Bases:
object
- class hastegeo.core.processors.train.TrainPostprocessor(model, image_layer=None, label_project=None, project=None, config=None)[source]#
Bases:
BaseTrainProcessor
Inference (hastegeo.core.processors.inference)#
Model inference execution and monitoring.
BaseInferenceProcessor— Base class for inference operationsInferencePreprocessor— Prepare and queue model inference requestsInferencePostprocessor— Execute and monitor inference jobsInferenceLogRecord— Timestamped inference log entry
- class hastegeo.core.processors.inference.BaseInferenceProcessor(model, image_layer, config=None)[source]#
Bases:
object
- class hastegeo.core.processors.inference.InferenceLogRecord(timestamp, message)[source]#
Bases:
NamedTuple
- class hastegeo.core.processors.inference.InferencePostprocessor(model, image_layer=None, experiment_config=None, config=None)[source]#
Bases:
BaseInferenceProcessor
Labels (hastegeo.core.processors.labels)#
Labeling task generation from imagery.
LabelTaskGenerator— Generate labeling tasks from imagery layers with optional grid-based subdivision
Metadata (hastegeo.core.processors.metadata)#
High-level metadata operations over the data layer.
MetadataProcessor— CRUD operations for project/model/user metadata with support for multiple storage backends
- class hastegeo.core.processors.metadata.MetadataProcessor(data_type, partition_key=None, config=None)[source]#
Bases:
objectProcessor for managing metadata storage and retrieval operations.
The MetadataProcessor provides a high-level interface for working with metadata in various storage backends. It handles data serialization, storage operations, and provides convenient methods for common metadata operations like saving, loading, and listing records.
- Parameters:
- storage#
Underlying storage layer instance.
- Type:
Example
>>> processor = MetadataProcessor('project', 'user_123') >>> processor.save('project_1', {'name': 'My Project'}) >>> project = processor.load('project_1')
- build_url(key, data_format='json')[source]#
Build a remote URL for a record without a per-item existence check.
Intended for callers that have already confirmed the record exists in bulk via
list_keys(). On the blob backend this avoids a network round-trip per key (the container read SAS is shared), so it is a local operation and is not counted as a storage round-trip.
- list_keys(data_format='json')[source]#
List the identifiers present for this data type in the partition.
A cheap, metadata-only alternative to
load_all_from_partitionfor bulk existence checks (does not download record contents).
- load_and_combine_sub_data_types(key, data_types)[source]#
Load and combine metadata from multiple data types.
- load_filtered(predicate, data_format='json')[source]#
Load partition records matching every key/value in
predicate.This is an explicit client-side fallback: the partition is loaded once and then filtered in process. Backends need a separate query primitive before this can reduce transferred records.
- load_map(keys, data_format='json', max_workers=None)[source]#
Load many records by key concurrently.
Returns
{key: record}; a key whose record is missing maps toNone(mirrors a per-keyloadthat raisesFileNotFoundError). Bounded parallelism overlaps per-key storage operations while the process-wide executor caps aggregate concurrency. Preserves perf instrumentation across worker threads by binding the active counter inside each task.
- load_page(page, page_size, data_format='json', target=None, status=None, project_id=None, max_records=None)[source]#
- save(key, metadata, data_format='json')[source]#
Save or upsert metadata to the backend storage.
This method performs an upsert operation - if metadata with the given key already exists, it will be updated; otherwise, new metadata will be created.
- Parameters:
Example
>>> processor.save('project_1', {'name': 'My Project', 'status': 'active'})
Statistics (hastegeo.core.processors.stats)#
Project statistics aggregation.
StatsPreProcessor— Queue stats update requestsStatsPostProcessor— Process stats updates (add/update/delete project entries)
Artifacts (hastegeo.core.processors.artifacts)#
Model artifact management, packaging, and download.
ArtifactProcessor— Manages model artifacts including zipping, downloading, and Azure Batch zip job submission
- class hastegeo.core.processors.artifacts.ArtifactProcessor(partition_key=None, config=None, model=None, model_artifacts=None)[source]#
Bases:
object- fetch_artifact(identifier=None, extra_partition_keys=None, src_path=None, dst_path=None)[source]#
Download the artifact from the storage.
- get_download_url(identifier=None, artifact_path=None, extra_partition_keys=None)[source]#
Get the download URL for the artifact.
Uploader (hastegeo.core.processors.uploader)#
Chunked file upload handling.
FileUploader— Process chunked file uploads with chunk storage and final assembly