Feluda Core API

This section documents the core Feluda modules and classes.

Main Feluda Class

class feluda.feluda.Feluda(config_path: str)[source]

Bases: object

Main class for Feluda.

__init__(config_path: str) None[source]

Initialize the Feluda framework with a configuration file.

Parameters:

config_path (str) – Path to the configuration file.

Configuration

class feluda.config.StoreESParameters(host_name: str, image_index_name: str, text_index_name: str, video_index_name: str, audio_index_name: str)[source]

Bases: object

Parameters for Elasticsearch store configuration.

host_name: str
image_index_name: str
text_index_name: str
video_index_name: str
audio_index_name: str
__init__(host_name: str, image_index_name: str, text_index_name: str, video_index_name: str, audio_index_name: str) None
class feluda.config.StorePostgresParameters(table_names: list[str])[source]

Bases: object

Parameters for PostgreSQL store configuration.

table_names: list[str]
__init__(table_names: list[str]) None
class feluda.config.StoreEntity(label: str, type: str, parameters: StoreESParameters | StorePostgresParameters)[source]

Bases: object

Entity configuration for the store.

label: str
type: str
parameters: StoreESParameters | StorePostgresParameters
__init__(label: str, type: str, parameters: StoreESParameters | StorePostgresParameters) None
class feluda.config.StoreConfig(entities: list[StoreEntity])[source]

Bases: object

Configuration for the store.

entities: list[StoreEntity]
__init__(entities: list[StoreEntity]) None
class feluda.config.QueueParameters(host_name: str, queues: list[dict])[source]

Bases: object

Parameters for queue configuration.

host_name: str
queues: list[dict]
__init__(host_name: str, queues: list[dict]) None
class feluda.config.QueueConfig(label: str, type: str, parameters: QueueParameters)[source]

Bases: object

Configuration for the queue.

label: str
type: str
parameters: QueueParameters
__init__(label: str, type: str, parameters: QueueParameters) None
class feluda.config.ServerParameters(port: int, type: str)[source]

Bases: object

Parameters for server configuration.

port: int
type: str
__init__(port: int, type: str) None
class feluda.config.ServerConfig(label: str, parameters: ServerParameters)[source]

Bases: object

Configuration for the server.

label: str
parameters: ServerParameters
__init__(label: str, parameters: ServerParameters) None
class feluda.config.OperatorParameters(name: str, type: str, parameters: object | None = None)[source]

Bases: object

Parameters for operator configuration.

name: str
type: str
parameters: object | None = None
__init__(name: str, type: str, parameters: object | None = None) None
class feluda.config.OperatorConfig(label: str, parameters: list[OperatorParameters])[source]

Bases: object

Configuration for operators.

label: str
parameters: list[OperatorParameters]
__init__(label: str, parameters: list[OperatorParameters]) None
class feluda.config.Config(store: StoreConfig | None, queue: QueueConfig | None, server: ServerConfig | None, operators: OperatorConfig | None)[source]

Bases: object

Main configuration class for the Feluda framework.

store: StoreConfig | None
queue: QueueConfig | None
server: ServerConfig | None
operators: OperatorConfig | None
__init__(store: StoreConfig | None, queue: QueueConfig | None, server: ServerConfig | None, operators: OperatorConfig | None) None
feluda.config.load(filepath: str) Config[source]

Load configuration from a YAML file and return a Config dataclass.

Base Operator

class feluda.operator.Operator[source]

Bases: ABC

Base class for all operators in the Feluda framework.

__init__() None[source]

Initialize the operator.

abstract run(file_path: str, *args, **kwargs)[source]

Execute main logic.

abstract cleanup() None[source]

Clean up any resources or memory.

abstract state() dict[source]

Return internal state.

Logger

class feluda.logger.Logger(module_name: str)[source]

Bases: object

Logger class to handle logging.

__init__(module_name: str) None[source]

Initialize the logger with a module name.

Parameters:

module_name (str) – Name of the module for logging.

info(msg: str, *args, **kwargs) None[source]

Log an info message.

debug(msg: str) None[source]

Log a debug message if in development environment.

exception(msg: str) None[source]

Log an exception message.

static prettyprint(msg: str) None[source]

Pretty-print a message.

error(msg: str, *args, **kwargs) None[source]

Log an error message.

Factory Modules

Audio Factory

class feluda.factory.audio_factory.AudioFactory[source]

Bases: object

Factory class for creating audio objects from various sources.

static make_from_url(audio_url: str) dict[source]

Create an audio object from a URL or S3 path.

static make_from_url_to_wav(audio_url: str) dict[source]

Create a WAV audio object from a URL.

static make_from_file_on_disk(audio_path: str) dict[source]

Create an audio object from a file on disk.

Image Factory

class feluda.factory.image_factory.ImageFactory[source]

Bases: object

Factory class for creating image objects from various sources.

static make_from_url(image_url: str) dict[source]

Create an image object from a URL.

static make_from_url_to_path(image_url: str, image_path: str | None = None) dict[source]

Create an image object from a URL and save it to a path.

static make_from_file_on_disk(image_path: str) dict[source]

Create an image object from a file on disk.

static make_from_file_on_disk_to_path(image_path: str) dict[source]

Create an image object from a file on disk and return its path.

static make_from_file_in_memory(image_data: werkzeug.datastructures.FileStorage) dict[source]

Create an image object from a file in memory.

S3 Factory

class feluda.factory.s3_factory.S3Factory[source]

Bases: object

Factory class for handling S3 operations.

aws_access_key_id = None
aws_secret_access_key = None
aws_region = None
aws_bucket = None
s3 = 's3'
static download_file_from_s3(bucket_name: str, file_key: str, local_file_path: str) None[source]

Download a file from S3 to a local path.

Text Factory

class feluda.factory.text_factory.TextFactory[source]

Bases: object

Factory class for creating text objects from various sources.

static make_from_url(text_url: str) dict[source]

Create a text object from a URL.

static make_from_file_on_disk(text_path: str) None[source]

Create a text object from a file on disk.

static make_from_file_in_memory(text_path: werkzeug.datastructures.FileStorage) None[source]

Create a text object from a file on disk.

Video Factory

class feluda.factory.video_factory.VideoFactory[source]

Bases: object

Factory class for creating video objects from various sources.

static make_from_url(video_url: str) dict[source]

Create a video object from a URL or S3 path.

static make_from_file_on_disk(video_path: str) dict[source]

Create a video object from a file on disk.

static make_from_file_in_memory(file_data: werkzeug.datastructures.FileStorage) dict[source]

Create a video object from a file in memory.