API Reference

This section contains the auto-generated API documentation from docstrings.

Core Modules

main

read

write

transform

gtfs

Utility Modules

config

Configuration and Logging Module

This module provides application configuration, AWS client setup, and logging configuration for the Amtrak Ingestion system.

amtraker_ingestion.chalicelib.config.s3_client

Configured S3 client for AWS operations.

Type:

boto3.client

amtraker_ingestion.chalicelib.config.AMTRAK_ENABLED

Flag to enable/disable Amtrak data processing.

Type:

bool

amtraker_ingestion.chalicelib.config.VIA_ENABLED

Flag to enable/disable VIA Rail data processing.

Type:

bool

amtraker_ingestion.chalicelib.config.BRIGHTLINE_ENABLED

Flag to enable/disable Brightline data processing.

Type:

bool

amtraker_ingestion.chalicelib.config.ENVIRONMENT

Current environment (PROD or DEV).

Type:

str

amtraker_ingestion.chalicelib.config.Functions
---------
amtraker_ingestion.chalicelib.config.setup_logging[source]

Configure application logging.

amtraker_ingestion.chalicelib.config.get_logger[source]

Get a logger instance for a module.

Parameters:

name (str)

Return type:

Logger

class amtraker_ingestion.chalicelib.config.JSONFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]

Bases: Formatter

JSON log formatter for structured Datadog log ingestion.

format(record)[source]

Format the specified record as text.

The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.

Parameters:

record (LogRecord)

Return type:

str

amtraker_ingestion.chalicelib.config.setup_logging()[source]

Configure logging for the application. Emits JSON-structured logs compatible with Datadog log ingestion via Forwarder.

amtraker_ingestion.chalicelib.config.get_logger(name)[source]

Get a logger instance for a specific module.

Args:

name: Usually __name__ from the calling module

Returns:

Logger instance configured with the application settings

Parameters:

name (str)

Return type:

Logger

amtraker_ingestion.chalicelib.config.lambda_metric(metric_name, value, tags=None)[source]
Parameters:
Return type:

None

amtraker_ingestion.chalicelib.config.get_dd_tags(provider=None, function_name=None)[source]

Return standard Datadog tags for a metric emission.

Parameters:
  • provider (str | None)

  • function_name (str | None)

Return type:

list[str]

constants

Constants and Configuration Values

This module defines constants used throughout the Amtrak Ingestion system, including API endpoints, S3 bucket names, file paths, and data schemas.

amtraker_ingestion.chalicelib.constants.AMTRAKER_API

URL for the Amtraker trains API endpoint.

Type:

str

amtraker_ingestion.chalicelib.constants.S3_BUCKET

Name of the S3 bucket for data storage.

Type:

str

amtraker_ingestion.chalicelib.constants.CSV_FIELDS

Field names for event CSV files.

Type:

list of str

amtraker_ingestion.chalicelib.constants.EASTERN_TIME

Eastern timezone for service date calculations.

Type:

ZoneInfo

class amtraker_ingestion.chalicelib.constants.Provider(*values)[source]

Bases: str, Enum

Enum of supported transit providers.

AMTRAK

Amtrak national passenger railroad.

Type:

str

VIA

VIA Rail Canada.

Type:

str

BRIGHTLINE

Brightline Florida high-speed rail.

Type:

str

AMTRAK = 'Amtrak'
VIA = 'VIA'
BRIGHTLINE = 'Brightline'

disk

s3_upload

timefilter

Data Models

amtraker.trainresponse

amtraker.train

amtraker.station

amtraker.train_alert

amtraker.stationmeta