Skip to main content

Common code for Python projects involving GCP, Pandas, and Spark.

Project description

Falgueras 🪴

PyPI version

Development framework for Python projects involving GCP, Pandas, and Spark.

The main goal is to accelerate development of data-driven projects by offering a unified framework for developers with different backgrounds, from software and data engineers to data scientists.

Set up

Base package: pip install falgueras (requieres Python>=3.10)

PySpark dependencies: pip install falgueras[spark] (PySpark 3.5.2)

PySpark libraries are optional to keep the package lightweight and because in most cases they are already provided by the environment. If you don't use falgueras PySpark dependencies, keep in mind that versions of the numpy, pandas and pyarrow packages were tested against PySpark version 3.5.2. Behavior with other versions may change.

Run Spark 3.5.2 applications locally in Windows from IntelliJ

try fast fail fast learn fast

For local Spark execution in Windows, the following environment variables must be set appropriately:

  • SPARK_HOME; version spark-3.5.2-bin-hadoop3.
  • HADOOP_HOME; same value than SPARK_HOME.
  • JAVA_HOME; recommended Java SDK 11.
  • PATH += %HADOOP_HOME%\bin, %JAVA_HOME%\bin.

%HADOOP_HOME%\bin must contain files winutils.exe and hadoop.dll, download from here.

Additionally, add findspark.init() at the beginning of the script in order to set and add environment variables and dependencies to sys.path.

Connect to BigQuery from Spark

As shown in the spark_session_utils.py, the SparkSession used must include the jar com.google.cloud.spark:spark-bigquery-with-dependencies_2.12:0.41.1 in order to communicate with BigQuery.

Packages

falgueras.common

Shared code between other packages and utils functions: datetime, json, enums, logging.

falgueras.gcp

The functionalities of various Google Cloud Platform (GCP) services are encapsulated within custom client classes. This approach enhances clarity and promotes better encapsulation.

For instance, Google Cloud Storage (GCS) operations are wrapped in the gcp.GcsClient class, which has an attribute that holds the actual storage.Client object from GCS. Multiple GcsClient instances can share the same storage.Client object.

falgueras.pandas

Pandas related code.

The pandas_repo.py file provides a modular and extensible framework for handling pandas DataFrame operations across various storage systems. Using the PandasRepo abstract base class and PandasRepoProtocol, it standardizes read and write operations while enabling custom implementations for specific backends such as BigQuery (BqPandasRepo). These implementations encapsulate backend-specific logic, allowing users to interact with data sources using a consistent interface.

BqPandasRepo uses gcp.BqClient to interact with BigQuery.

falgueras.spark

Spark related code.

In the same way than the pandas_repo.py file, the spark_repo.py file provides a modular and extensible framework for handling Spark DataFrame operations across various storage systems. Using the SparkRepo abstract base class and SparkRepoProtocol, it standardizes read and write operations while enabling custom implementations for specific backends such as BigQuery (BqSparkRepo). These implementations encapsulate backend-specific logic, allowing users to interact with data sources using a consistent interface.

In contrast to BqPandasRepo, BqSparkRepo uses connectors gcs-connector-hadoop3 and spark-bigquery-with-dependencies in order to interact with BigQuery.

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

falgueras-1.1.1.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

falgueras-1.1.1-py3-none-any.whl (27.4 kB view details)

Uploaded Python 3

File details

Details for the file falgueras-1.1.1.tar.gz.

File metadata

  • Download URL: falgueras-1.1.1.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for falgueras-1.1.1.tar.gz
Algorithm Hash digest
SHA256 ea1107c38e79ae4fd1877d7c7e8425a7aa3cc0967bbdf9a6a18d65b2e14834ed
MD5 b310e8066c774e89ebccc4b259a98b6b
BLAKE2b-256 ff8c840c543b9f54d0513cf8dd4818d1a0ed1668731b121ee9ecec48705a58b3

See more details on using hashes here.

File details

Details for the file falgueras-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: falgueras-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 27.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for falgueras-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1a66e3819014270535c5996b3e14ffe7c755ab97ead67d2adf0050917440be04
MD5 ff07d5f0221e19db8b43a9cd886c90db
BLAKE2b-256 aa0afee083c4f7cef4e74b1f854993525d06c22a08269bd3824b5b9dbabcb3ee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page