-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from USACE/dev
Ready for review
- Loading branch information
Showing
49 changed files
with
3,678 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/python | ||
{ | ||
"name": "Python 3", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"image": "mcr.microsoft.com/devcontainers/python:0-3.11", | ||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "sudo chown -R vscode ./ && git config --global --add safe.directory ./ && pip3 install --user -r requirements.txt", | ||
// Configure tool-specific properties. | ||
"customizations": { | ||
"settings": { | ||
"python.defaultInterpreterPath": "/usr/local/bin/python", | ||
"python.linting.enabled": true, | ||
"python.linting.pylintEnabled": true, | ||
"editor.defaultFormatter": "ms-python.python", | ||
"python.formatting.provider": "black", | ||
"python.formatting.blackPath": "/usr/local/py-utils/bin/black", | ||
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint", | ||
"editor.formatOnSave": true, | ||
"python.languageServer": "Pylance", | ||
"python.linting.lintOnSave": true, | ||
"python.analysis.extraPaths": [ | ||
"${workspaceFolder}/src" | ||
] | ||
}, | ||
"vscode": { | ||
"extensions": [ | ||
"ms-python.python", | ||
"njpwerner.autodocstring", | ||
"ms-python.pylint" | ||
] | ||
} | ||
}, | ||
"remoteUser": "vscode", | ||
"containerUser": "vscode", | ||
"workspaceMount": "", | ||
"runArgs": [ | ||
"--volume=${localWorkspaceFolder}:/workspaces/${localWorkspaceFolderBasename}:Z" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Lint and Test | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.10", "3.11"] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Run pytest and pylint | ||
run: | | ||
pytest | ||
pylint --fail-under=9 src/cc_sdk/*.py | ||
- name: Stop the build if there are any linting errors or test failures | ||
run: | | ||
if [ $? -eq 0 ]; then | ||
echo "All tests and linting passed." | ||
else | ||
echo "There are test failures or linting errors. Aborting the build." >&2 | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
.pytest_cache/ | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# DotEnv configuration | ||
.env | ||
|
||
# Database | ||
*.db | ||
*.rdb | ||
|
||
# Pycharm | ||
.idea | ||
|
||
# vscode | ||
.vscode/ | ||
|
||
# Spyder | ||
.spyproject/ | ||
|
||
# Jupyter NB Checkpoints | ||
.ipynb_checkpoints/ | ||
|
||
# Mac OS-specific storage files | ||
.DS_Store | ||
|
||
# vim | ||
*.swp | ||
*.swo | ||
|
||
# Mypy cache | ||
.mypy_cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[FORMAT] | ||
max-line-length=120 | ||
disable = missing-docstring, unnecessary-lambda-assignment | ||
min-public-methods=0 | ||
# Set the Python path | ||
init-hook='import sys; sys.path.append("./src")' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
# cc-python-sdk | ||
# cc-python-sdk | ||
The Python SDK for developing plugins for Cloud Compute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[pytest] | ||
pythonpath = src | ||
testpaths = tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
astroid==2.15.0 | ||
attrs==22.2.0 | ||
boto3==1.26.93 | ||
botocore==1.29.93 | ||
certifi==2022.12.7 | ||
cffi==1.15.1 | ||
charset-normalizer==3.1.0 | ||
cryptography==39.0.2 | ||
dill==0.3.6 | ||
idna==3.4 | ||
iniconfig==2.0.0 | ||
isort==5.12.0 | ||
Jinja2==3.1.2 | ||
jmespath==1.0.1 | ||
lazy-object-proxy==1.9.0 | ||
MarkupSafe==2.1.2 | ||
mccabe==0.7.0 | ||
moto==4.1.4 | ||
packaging==23.0 | ||
platformdirs==3.1.1 | ||
pluggy==1.0.0 | ||
pycparser==2.21 | ||
pylint==2.17.0 | ||
pytest==7.2.2 | ||
python-dateutil==2.8.2 | ||
PyYAML==6.0 | ||
requests==2.28.2 | ||
responses==0.23.1 | ||
s3transfer==0.6.0 | ||
six==1.16.0 | ||
tomlkit==0.11.6 | ||
types-PyYAML==6.0.12.8 | ||
urllib3==1.26.15 | ||
Werkzeug==2.2.3 | ||
wrapt==1.15.0 | ||
xmltodict==0.13.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from .data_store import * | ||
from .aws_config import * | ||
from .data_source import * | ||
from .store_type import * | ||
from .payload import * | ||
from .get_object_input import * | ||
from .pull_object_input import * | ||
from .put_object_input import * | ||
from .config import * | ||
from . import constants | ||
from . import environment_variables | ||
from .message import Message | ||
from .error import Error, ErrorLevel, ErrorLevelOptions | ||
from .status import Status, StatusLevel | ||
from .seed_set import SeedSet | ||
from .cc_store import CCStore | ||
from .file_data_store import FileDataStore | ||
from .cc_store_s3 import CCStoreS3 | ||
from .json_encoder import EnumEncoder | ||
from .file_data_store_s3 import FileDataStoreS3 | ||
from .plugin_manager import PluginManager | ||
|
||
__all__ = [ | ||
"DataStore", | ||
"AWSConfig", | ||
"DataSource", | ||
"StoreType", | ||
"Payload", | ||
"GetObjectInput", | ||
"PullObjectInput", | ||
"PutObjectInput", | ||
"Config", | ||
"constants", | ||
"environment_variables", | ||
"Message", | ||
"Error", | ||
"ErrorLevel", | ||
"ErrorLevelOptions", | ||
"Status", | ||
"StatusLevel", | ||
"SeedSet", | ||
"CCStore", | ||
"FileDataStore", | ||
"CCStoreS3", | ||
"EnumEncoder", | ||
"FileDataStoreS3", | ||
"PluginManager", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import json | ||
from attr import define, field, asdict, validators | ||
|
||
|
||
@define(auto_attribs=True) | ||
class AWSConfig: | ||
""" | ||
This class provides configuration settings for using an AWS S3 data store. | ||
Attributes: | ||
- aws_config_name: str | ||
The name of the AWS configuration (optional). | ||
- aws_access_key_id : str | ||
The AWS access key ID to use for accessing the data store (optional). | ||
- aws_secret_access_key_id : str | ||
The AWS secret access key ID to use for accessing the data store (optional). | ||
- aws_region : str | ||
The AWS region where the data store is located (optional). | ||
- aws_bucket : str | ||
The name of the AWS S3 bucket to use as the data store (optional). | ||
- aws_mock : bool | ||
Whether to use a mock AWS S3 data store (optional, default is False). | ||
- aws_endpoint : str | ||
The endpoint URL for the AWS S3 data store (optional). | ||
- aws_disable_ssl : bool | ||
Whether to disable SSL when connecting to the AWS S3 data store (optional, default is False). | ||
- aws_force_path_style : bool | ||
Whether to use path-style addressing for the AWS S3 data store (optional, default is False). | ||
Methods: | ||
- serialize(): Returns a JSON string representation of the attributes. | ||
Raises: | ||
- TypeError: | ||
If the wrong type of object is set for an attribute. | ||
""" | ||
|
||
aws_config_name: str = field(default="", validator=[validators.instance_of(str)]) | ||
aws_access_key_id: str = field(default="", validator=[validators.instance_of(str)]) | ||
aws_secret_access_key_id: str = field( | ||
default="", validator=[validators.instance_of(str)] | ||
) | ||
aws_region: str = field(default="", validator=[validators.instance_of(str)]) | ||
aws_bucket: str = field(default="", validator=[validators.instance_of(str)]) | ||
aws_mock: bool = field(default=False, validator=[validators.instance_of(bool)]) | ||
aws_endpoint: str | None = field( | ||
default=None, validator=[validators.instance_of(str | None)] | ||
) | ||
aws_disable_ssl: bool = field( | ||
default=False, validator=[validators.instance_of(bool)] | ||
) | ||
aws_force_path_style: bool = field( | ||
default=False, validator=[validators.instance_of(bool)] | ||
) | ||
|
||
def serialize(self) -> str: | ||
""" | ||
Serializes the AWSConfig object to a JSON string. | ||
Returns: | ||
str: JSON string representation of the attributes. | ||
""" | ||
return json.dumps(asdict(self)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import abc | ||
from .payload import Payload | ||
from .store_type import StoreType | ||
from .get_object_input import GetObjectInput | ||
from .pull_object_input import PullObjectInput | ||
from .put_object_input import PutObjectInput | ||
|
||
class CCStore(metaclass=abc.ABCMeta): | ||
"""A base class for implementing a data store. | ||
This class defines a set of abstract methods for storing and retrieving | ||
data. To use this class, you must create a subclass and implement each of | ||
the abstract methods. | ||
Attributes: | ||
None | ||
Methods: | ||
- put_object(input): stores the given input in the store, returns true | ||
on success and false on failure | ||
- pull_object(input): retrieves the input from the store, returns true | ||
on success and false on failure | ||
- get_object(input): retrieves the object bytes from the store | ||
- get_payload(): retrieves the payload from the store | ||
- root_path(): retrieves the root path of the store | ||
- handles_data_store_type(datastore_type): returns whether the given | ||
data store type is handled by this class | ||
""" | ||
|
||
@abc.abstractmethod | ||
def put_object(self, put_input: PutObjectInput) -> bool: | ||
pass | ||
|
||
@abc.abstractmethod | ||
def pull_object(self, pull_input: PullObjectInput) -> bool: | ||
pass | ||
|
||
@abc.abstractmethod | ||
def get_object(self, get_input: GetObjectInput) -> bytes: | ||
pass | ||
|
||
@abc.abstractmethod | ||
def get_payload(self) -> Payload: | ||
pass | ||
|
||
@abc.abstractmethod | ||
def root_path(self) -> str: | ||
pass | ||
|
||
@abc.abstractmethod | ||
def handles_data_store_type(self, data_store_type: StoreType) -> bool: | ||
pass |
Oops, something went wrong.