fyda API Guide

Loading Data

fyda.load(file_name, **kwargs)[source]

Load data intelligently.

Parameters:file_name (str or path-like) – Files to load. These can be shortcuts or file paths.
fyda.load_s3(file_name, bucket_name=None, reader=None, **kwargs)[source]

Read a file from S3.

Parameters:
  • file_name (str) – Absolute name of the file object as represented in S3 bucket.
  • bucket_name (str, (optional)) – Bucket to load object from. If none used, uses bucket specification in .fydarc.
  • reader (callable, (optional)) – Function capable of reading the file. If none is passed, one will be automatically assigned based on the file extension.
  • kwargs – Additional keyword arguments to pass to file reader.
Returns:

As read by reader object

Return type:

data

fyda.data_path(shortcut, root=None)[source]

Return the absolute path to the file referenced by shortcut.

Parameters:
  • shortcut (str) – Shortcut reference for the file.
  • root (str) – Root directory to use with DataBank.
Returns:

path – Absolute path to file.

Return type:

str

DataBank

class fyda.DataBank(root=None, error='ignore')[source]

Interact with the system’s data automatically.

Parameters:root (str) – Path to root data folder. If none is provided, uses the default from .fydarc given by the conf_path parameter.

Properties

DataBank.tree Full tree of data root directory in python dictionary form.
DataBank.shortcuts Mapping of shortcuts to absolute paths.
DataBank.readers Mapping of shortcuts to their respective readers.

Methods

DataBank.deposit(filepath[, shortcut, …]) Store a shortcut and reader reference for the given file name.
DataBank.determine_shortcut(filepath) Get the shortcut for a filepath based on already deposited values.
DataBank.encoding_level(fileref) Get the encoding level for given file reference.
DataBank.rebase_shortcuts(filepath) Detect if the filepath will cause a duplication conflict, and rebase if necessary.
DataBank.root_to_dict(root[, auto_deposit, …]) Recursively convert root folder to native Python dictionary.
DataBank.withdraw(data_name[, reader, …]) Automatically load data, given shortcut to file.

ProjectConfig

class fyda.ProjectConfig(make_config=True)[source]

Configuration manager.

Notes

This class is a wrapper around configparser.ConfigParser with the added benefit of automatically reading the configuration file on instantiation. If the configuration file doesn’t exist when ConfigParser is called, it is created in the environment automatically.

See also

configparser.ConfigParser : configuration parsing class