Skip to content

Commit

Permalink
Feature/migrate jpl tig (#5)
Browse files Browse the repository at this point in the history
* merge in jpl tig and update python libraries

* fix upload artifact version

* fix pytlint flake pytest

* fix pylint

* update github actions

* update changelog

* update pyproject.toml

* add in release creation workflow

* make develop 0.7.0-alpha.1
  • Loading branch information
sliu008 authored Sep 6, 2023
1 parent a31f262 commit dff8dc1
Show file tree
Hide file tree
Showing 17 changed files with 1,836 additions and 1,229 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/.release-created.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

name: Release Branch Created

# Run whenever a ref is created https://docs.github.com/en/actions/reference/events-that-trigger-workflows#create
on:
create

jobs:
# First job in the workflow builds and verifies the software artifacts
bump:
name: Bump minor version on develop
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Only run if ref created was a release branch
if:
${{ startsWith(github.ref, 'refs/heads/release/') }}
steps:
# Checks-out the develop branch
- uses: actions/checkout@v2
with:
ref: 'refs/heads/develop'
- uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install Poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.3.2
- name: Bump minor version
env:
COMMIT_VERSION: ${{ github.ref }}
run: |
# only update the develop branch if were making #.#.0 release
# Get the branch name from the GITHUB_REF environment variable
branch_name=${GITHUB_REF#refs/heads/}
# Extract the last number in the branch name using a regular expression
if [[ $branch_name =~ /([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
first_number=${BASH_REMATCH[1]}
middle_number=${BASH_REMATCH[2]}
last_number=${BASH_REMATCH[3]}
# Increment the middle number by 1
incremented_middle_number=$((middle_number + 1))
# Check if the last number is '0'
if [ "$last_number" == "0" ]; then
update_version=$first_number.$incremented_middle_number.$last_number-alpha.1
poetry version $update_version
echo "software_version=$update_version" >> $GITHUB_ENV
git config --global user.name 'podaac-tig bot'
git config --global user.email '[email protected]'
git commit -am "/version ${{ env.software_version }}"
git push
fi
fi
13 changes: 6 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ jobs:
# These are gradle-specific steps for installing the application
- name: Install Software
run: |
pip install setuptools -U \
pip install pylint \
pip install pytest \
pip install setuptools -U
pip install pylint
pip install pytest
poetry install
Expand Down Expand Up @@ -240,9 +240,8 @@ jobs:
# This is where tests go
- name: Run Poetry Tests
run: |
poetry run pylint podaac \
poetry run flake8 podaac \
poetry run pytest --help \
poetry run pylint podaac
poetry run flake8 podaac
poetry run pytest --junitxml=build/reports/pytest.xml --cov=podaac/ --cov-report=html -m "not aws and not integration" tests/
# poetry run pytest --junitxml=build/reports/pytest.xml --cov=podaac/ --cov-report=xml:build/reports/coverage.xml -m "not aws and not integration" tests/

Expand Down Expand Up @@ -298,7 +297,7 @@ jobs:
- name: Upload Release Artifacts
uses: ncipollo/[email protected]
with:
tag: ${{ env.the_version }}
tag: ${{ env.new_version }}
artifacts: "*.zip"
token: ${{ secrets.GITHUB_TOKEN }}

Expand Down
81 changes: 5 additions & 76 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -60,85 +60,14 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use "--disable=all --enable=classes
# --disable=W".
disable=print-statement,
parameter-unpacking,
unpacking-in-except,
old-raise-syntax,
backtick,
long-suffix,
old-ne-operator,
old-octal-literal,
import-star-module-level,
non-ascii-bytes-literal,
raw-checker-failed,
disable=raw-checker-failed,
bad-inline-option,
locally-disabled,
file-ignored,
suppressed-message,
useless-suppression,
deprecated-pragma,
use-symbolic-message-instead,
apply-builtin,
basestring-builtin,
buffer-builtin,
cmp-builtin,
coerce-builtin,
execfile-builtin,
file-builtin,
long-builtin,
raw_input-builtin,
reduce-builtin,
standarderror-builtin,
unicode-builtin,
xrange-builtin,
coerce-method,
delslice-method,
getslice-method,
setslice-method,
no-absolute-import,
old-division,
dict-iter-method,
dict-view-method,
next-method-called,
metaclass-assignment,
indexing-exception,
raising-string,
reload-builtin,
oct-method,
hex-method,
nonzero-method,
cmp-method,
input-builtin,
round-builtin,
intern-builtin,
unichr-builtin,
map-builtin-not-iterating,
zip-builtin-not-iterating,
range-builtin-not-iterating,
filter-builtin-not-iterating,
using-cmp-argument,
eq-without-hash,
div-method,
idiv-method,
rdiv-method,
exception-message-attribute,
invalid-str-codec,
sys-max-int,
bad-python3-import,
deprecated-string-function,
deprecated-str-translate-call,
deprecated-itertools-function,
deprecated-types-field,
next-method-defined,
dict-items-not-iterating,
dict-keys-not-iterating,
dict-values-not-iterating,
deprecated-operator-function,
deprecated-urllib-function,
xreadlines-attribute,
deprecated-sys-function,
exception-escape,
comprehension-escape,
too-many-arguments,
too-many-locals
# Enable the message, report, category or checker with the given id(s). You can
Expand Down Expand Up @@ -331,8 +260,8 @@ max-module-lines=1000
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
# `empty-line` allows space-only lines.
no-space-check=trailing-comma,
dict-separator
#no-space-check=trailing-comma,
# dict-separator

# Allow the body of a class to be on the same line as the declaration if body
# contains single statement.
Expand Down Expand Up @@ -567,7 +496,7 @@ min-public-methods=2

# Exceptions that will emit a warning when being caught. Defaults to
# "BaseException, Exception".
overgeneral-exceptions=BaseException,
Exception
#overgeneral-exceptions=BaseException,
# Exception

disable=consider-using-f-string, W1514, R0402, R1730
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Security


## [0.6.0]

### Added
- ** Issue-2 **
- Add lambda to clean up cma messages with descriptions
- Add in variable description for images generated
### Changed
### Deprecated
### Removed
### Fixed
### Security

## [0.5.0]

### Added
- **PODAAC-5277**
- Update tig to handle multipe lon and lats for different groups
- Update some python libraries for snyk and cma python
- **PODAAC-5541**
- Replace spaces " " with "_" to handle group names with spaces
- Fixes collection AQUARIUS_L2_SSS_V5
### Changed
### Deprecated
### Removed
### Fixed
### Security

## [0.4.0]

### Added
Expand Down
68 changes: 68 additions & 0 deletions podaac/lambda_handler/clean_lambda_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""lambda function used for image generation in aws lambda with cumulus"""

import logging
import os
from cumulus_logger import CumulusLogger
from cumulus_process import Process

cumulus_logger = CumulusLogger('tig_lambda_message_cleaner')


class CMACleaner(Process):
"""
A class to help clean up the CMA message after running tig.
"""

def __init__(self, *args, **kwargs):

super().__init__(*args, **kwargs)
self.logger = cumulus_logger

def process(self):
"""Main process to generate images for granules
Returns
----------
dict
Payload that is returned to the cma which is a dictionary with list of granules
"""

granules = self.input['granules']

for granule in granules:
for file in granule['files']:
if 'description' in file:
del file['description']

return self.input


def handler(event, context):
"""handler that gets called by aws lambda
Parameters
----------
event: dictionary
event from a lambda call
context: dictionary
context from a lambda call
Returns
----------
string
A CMA json message
"""

# pylint: disable=duplicate-code
levels = {
'critical': logging.CRITICAL,
'error': logging.ERROR,
'warn': logging.WARNING,
'warning': logging.WARNING,
'info': logging.INFO,
'debug': logging.DEBUG
}
logging_level = os.environ.get('LOGGING_LEVEL', 'info')
cumulus_logger.logger.level = levels.get(logging_level, 'info')
cumulus_logger.setMetadata(event, context)
return CMACleaner.cumulus_handler(event, context=context)
Loading

0 comments on commit dff8dc1

Please sign in to comment.