pyfan.aws.general.path

The pyfan.aws.general.path file paths etc

Includes method detect_store_path(), save_img().

Module Contents

Functions

detect_store_path(bl_check_path_exist=True, srt_sub_path=None, st_local_path=None)

Detects checks if program is running on an AWS Linux Instance

save_img(plt, sna_image_name, spt_image_path=None, dpi=300, papertype='a4', orientation='horizontal', bl_upload_s3=False, st_s3_bucket=None, srt_s3_bucket_folder=None)

Saves Graph Locally, and also upload to S3 if requested

pyfan.aws.general.path.detect_store_path(bl_check_path_exist=True, srt_sub_path=None, st_local_path=None)[source]

Detects checks if program is running on an AWS Linux Instance

In our case, all code that run on AWS linux are running inside conda containers. If running on container, save to data folder. If running on some local machine save results to the user’s home path’s download folder, data subfolder.

Parameters
bl_check_path_existbool

checking saving path if it does not exist

srt_sub_path: `string`, optional

this is the subpath to be used, in the data folder in EC2 container, or inside the downloads data folder under user directory.

st_local_path: `string`, optional

local overriding string save path, if not, use download/data folder. This will replace the local path

Returns
tuple[bool, string]

returns boolean if on amzn splatform, then the directory where to store save files

pyfan.aws.general.path.save_img(plt, sna_image_name, spt_image_path=None, dpi=300, papertype='a4', orientation='horizontal', bl_upload_s3=False, st_s3_bucket=None, srt_s3_bucket_folder=None)[source]

Saves Graph Locally, and also upload to S3 if requested

Given figure object,

Parameters
plt: `matplotlib.pyplot`

a matplotlib pyplot object from a graph that was just generated

sna_image_name: `string`

image name, without the suffix of png

spt_image_path: `string`, optional

path to image, if None, then use default local path in detect_store_path()

dpi: `integer`, optional

image dpi

papertype: `string`, optional

One of ‘letter’, ‘legal’, ‘executive’, ‘ledger’, ‘a0’ through ‘a10’, ‘b0’ through ‘b10’.

orientation: `string`, optional

‘horizontal’ or ‘portrait’

bl_upload_s3: `bool`, optional

if file will be uploaded to s3

st_s3_bucket: `string`, optional

Assuming that AWS credentials are already stored in the container on EC2 or locally in a .aws credential file. So st_s3_bucket bucket name refers to bucket in the credentialed user’s s3 account.

srt_s3_bucket_folder: `string`, optional

folder in s3 bucket to store image

Returns
tuple[bool, string]

returns boolean if on amzn splatform, then the directory where to store save files