landingai.storage
download_file(url, file_output_path=None)
Download a file from a public url. This function will follow HTTP redirects
Parameters
url : str Source url file_output_path : Optional[Path], optional The local output file path for the downloaded file. If no path is provided, the file will be saved into a temporary directory provided by the OS (which could get deleted after reboot), and when possible the extension of the downloaded file will be included in the output file path.
Returns
Path Path to the downloaded file
Source code in landingai/storage/data_access.py
fetch_from_uri(uri, **kwargs)
Check if the URI is local and fetch it if it is not
Parameters
uri : str Supported URIs - local paths - file:// - http:// - https://
Returns
Path Path to a local resource
Source code in landingai/storage/data_access.py
read_file(url)
Read bytes from a URL. Typically, the URL is a presigned URL (for example, from Amazon S3 or Snowflake) that points to a video or image file. Returns
Dict[str, Any] Returns the content under "content". Optionally may return "filename" in case the server provided it.
Source code in landingai/storage/data_access.py
SnowflakeCredential
Bases: BaseSettings
Snowflake API credential. It's used to connect to Snowflake. It supports loading from environment variables or .env files.
The supported name of the environment variables are (case-insensitive): - SNOWFLAKE_USER - SNOWFLAKE_PASSWORD - SNOWFLAKE_ACCOUNT
Environment variables will always take priority over values loaded from a dotenv file.
Source code in landingai/storage/snowflake.py
SnowflakeDBConfig
Bases: BaseSettings
Snowflake connection config. It supports loading from environment variables or .env files.
The supported name of the environment variables are (case-insensitive): - SNOWFLAKE_WAREHOUSE - SNOWFLAKE_DATABASE - SNOWFLAKE_SCHEMA
Environment variables will always take priority over values loaded from a dotenv file.
Source code in landingai/storage/snowflake.py
get_snowflake_presigned_url(remote_filename, stage_name, *, credential=None, connection_config=None)
Get a presigned URL for a file stored in Snowflake. NOTE: Snowflake returns a valid URL even if the file doesn't exist. So the downstream needs to check if the file exists first.
Source code in landingai/storage/snowflake.py
save_remote_file_to_local(remote_filename, stage_name, *, local_output=None, credential=None, connection_config=None)
Save a file stored in Snowflake to local disk. If local_output is not provided, a temporary directory will be created and used. If credential or connection_config is not provided, it will read from environment variable or .env file instead.