AWS File Helper for Easier I/O
Project description
AWS File Helper (awsfile-helper)
Content Management and Retrieval for Cloud and Local Storage
Code Usage (Authorization)
You must have an AWS Access Key and Secret Access key to connect to AWS.
Upon obtaining these keys, use
from baseblock import CryptoBase
os.environ['AWS_ACCESS_KEY'] = CryptoBase().encrypt_str('<my-access-key>')
os.environ['AWS_SECRET_KEY'] = CryptoBase().encrypt_str('<my-secret-key>')
This will place your encrypted credentials into the environment.
The AwsAPI
class will retrieve and decrypt these credentials to login.
Code Usage (General)
The following code will retrieve any file:
from awsfile_helper import FindOwlFile
d_cloud_file = FindS3File(
file_name='config/graphviz/stylesheets/nlu',
file_ext='yaml', file_version='0.1.0').process()
The bucket is assumed to be data-core-bast
.
We can modify this assumption down the road if we create new buckets for different clients, etc.
A file may also be retrieved without a version, like this:
d_cloud_file = FindS3File(
file_name='config/graphviz/stylesheets/nlu',
file_ext='yaml').process()
In that case, the system will first look in the environment, using a key configuration that relies on the file_name
like this: CONFIG_GRAPHVIZ_STYLESHEETS_NLU_VERSION
. If no value is found in the environment, the system will consider this a wildcard match and set the version to *
. This forces the system to list the contents of the qualified path and choose the latest version. This operation takes an additional 2-3 milliseconds, assuming the network is running smoothly.
Code Usage (Ontologies)
Ontologies require a special finder class, because we typically have two files we want to retrieve - an OWL model and a TXT file with synonyms.
Therefore, assume that an S3 bucket exists with two files we want to retrieve: syllabus.owl
and syllabus.txt
.
The following code will retrieve these files:
from awsfile_helper import FindOwlFile
d_cloud_file = FindOwlFile(file_name='syllabus', version='0.1.0').process()
Note that we did not specify the file extension within the file_name
variable.
It is permissible to specify explicit file names such as syllabus.txt
or partial file names such.
The result dictionary is keyed by file name and (with redacted contents) looks like this:
{
"owl": {
"path": "<local path to OWL file">,
"version": "<version of OWL file>",
"contents": "<contents of OWL file>"
},
"txt": {
"path": "<local path to txt file">,
"version": "<version of txt file>",
"contents": "<contents of txt file>"
}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file awsfile_helper-0.1.18.tar.gz
.
File metadata
- Download URL: awsfile_helper-0.1.18.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.8.5 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d558c05384157b5257e80a988017327fa2901bce3ce0a7c9ff05727fc0cdd75 |
|
MD5 | 1e86175b20d2f960e00a0f62a8359f85 |
|
BLAKE2b-256 | 2406388c030cd900b2f8a431d73cefd55bd5221e4a4e0b8564d8d9618e299d02 |
File details
Details for the file awsfile_helper-0.1.18-py3-none-any.whl
.
File metadata
- Download URL: awsfile_helper-0.1.18-py3-none-any.whl
- Upload date:
- Size: 24.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.8.5 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04abdba6eddf0cd974aede8ff2f29f63ee155f94cdb38d2fae6889f11114b72a |
|
MD5 | 1b59fea739a227f6d1fa529d5edde1b8 |
|
BLAKE2b-256 | 18a083f6067eb02d435171f7af5f20d671867b93a14caead5d287eadcf17c6eb |