Data Flow S3 Importer
This package helps Python and Django projects import data exposed by Data Flow into an S3 bucket.
Data Flow is a data pipeline service that can be made to write data into S3 buckets for ingestion by client applications.
This package will use boto to connect to the given bucket, find the right location within the bucket and read the list of files in there.
It will then take a single file and process it line by line, expecting a JSON object with an 'object' key containing a single entity on each line:
...
{"object": {...}}
...
It is possible to override the base class for plain python projects, or the subclass for Django projects.
The subclass will process each object into an instance of the given model, which will be saved to the DB.
If the model inherits from the provided IngestedModel, any instances not included in the most recent fetch will be flagged as deleted upstream and won't by default appear in the queryset, although they won't be deleted.
Usage
Make a subclass for each of the record sets you want to import.
Plain python
If you're not using Django, or you want full control over how your models are synced (for example you don't want to use queryset methods to update them) then you should subclass the DataFlowS3Ingest ingester class.
This class provides various hooks for configuration and processing; the config you'll need can be applied in the subclass attributes as follows
from data_flow_s3_import.ingest import DataFlowS3Ingest
class MyIngest(DataFlowS3Ingest):
export_bucket = "my_bucket_name"
export_path = "bucket_import_type_prefix"
export_directory = "ingested_data_prefix/"
def get_s3_resource(self):
# this should return a configured and instantiated boto3 S3 resource
You will then want to override process_object and/or the other hooks in the class provided as suits your requirements.
Instantiating the class will run the ingestion automatically.
Standard Django models
If you're using Django and want to have your import process automated, start by making a custom model in your app, extending IngestedModel
from data_flow_s3_import.models import IngestedModel
class MyIngestedModel(IngestedModel):
...
You will also want to subclass the DataFlowS3IngestToModel importer, setting the mapping dictionary with the key being the model field name and the value being the imported data column name
from data_flow_s3_import.ingest import DataFlowS3IngestToModel
class MyModelIngest(DataFlowS3IngestToModel):
model = MyIngestedModel
mapping = {
"id": "importedColumns:id",
"name": "importedColumns:NameField",
}
And then simply instantiate your class and the ingestion will run automatically, syncing your models with the ingested records
MyModelIngest(s3_resource=boto_s3_instance, bucket_name="my_bucket")
You will also need to configure the S3, bucket and path information as in the plain python implementation.
Metadata
Release files for data-flow-s3-import 0.1.0
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 | Actions |
|---|---|---|---|---|
| data_flow_s3_import-0.1.0.tar.gz | 10.2 kB | Without provenance | Details for data_flow_s3_import-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| data_flow_s3_import-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for data_flow_s3_import-0.1.0-py3-none-any.whl |
Total release size: 21.7 kB
Release files / data_flow_s3_import-0.1.0.tar.gz
| Download URL | data_flow_s3_import-0.1.0.tar.gz |
|---|---|
| Size | 10.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cad511ffc57d22d95213a4eb5c71cf91be6888c839428373cf791da46aa26885
|
|
BLAKE2b-256 checksum How to use checksums |
f06a5a7a40cecf6278b7947263103c8d149d7651542acd98aa84623fd303dd65
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.1 CPython/3.12.2 Darwin/24.5.0
|
Release files / data_flow_s3_import-0.1.0-py3-none-any.whl
| Download URL | data_flow_s3_import-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d76fa4e79a4c77585e38e6349662e53c5f948475eccc55c29778262f3854fd20
|
|
BLAKE2b-256 checksum How to use checksums |
d37e82f744cda8a03b6c334b7f260eb7e1c90d072ffc650c60fb06d8135a947a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.1 CPython/3.12.2 Darwin/24.5.0
|
Security for data-flow-s3-import 0.1.0
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.