Skip to content

Commit

Permalink
Merge pull request #12 from ircwaves/update-to-support-workflow-event…
Browse files Browse the repository at this point in the history
…-manager

Update to support workflow event manager
  • Loading branch information
ircwaves authored May 15, 2024
2 parents 715a155 + 4b33b0f commit 39a8a94
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 22 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand All @@ -39,7 +39,10 @@ jobs:
- name: Test with pytest
run: pytest --cov=cirrus --cov-report=xml
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v3
if: ${{ matrix.python-version == '3.12' }}
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
fail_ci_if_error: true
verbose: true
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Support for `cirrus-geo>=0.15.0` with WorkflowEventManager changes around
ProcessPayloads. ([#12])
- Added support for Python 3.12

### Changed

- Given the heavy changes initiated with
[cirrus-geo#268](https://github.com/cirrus-geo/cirrus-geo/pull/268),
`cirrus-mgmt` is now pinned to use the stable releases of cirrus-geo
(`<1.0`). As described, in that PR, the management commands for releases
`>=1.0` will not use this separate package.
- Updated Github Actions per nodejs16 deprecation notice in workflows.

### Removed

- Python support for python 3.8.

## [v0.1.1] - 2024-02-16

### Fixed
Expand Down Expand Up @@ -36,3 +57,4 @@ Initial release
[v0.1.1]: https://github.com/cirrus-geo/cirrus-mgmt/compare/v0.1.0...v0.1.1
[v0.1.0]: https://github.com/cirrus-geo/cirrus-mgmt/compare/v0.1.0a...v0.1.0
[v0.1.0a]: https://github.com/cirrus-geo/cirrus-mgmt/releases/tag/v0.1.0a
[#12]: https://github.com/cirrus-geo/cirrus-mgmt/pull/12
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
click-option-group>=0.5.5
cirrus-geo>=0.9.0
cirrus-geo>=0.9.0,<1
backoff>=2.2.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
classifiers=[
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
license="Apache-2.0",
include_package_data=True,
Expand Down
7 changes: 2 additions & 5 deletions src/cirrus/plugins/management/commands/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
import logging
import sys
from functools import wraps
from subprocess import CalledProcessError

import click
from cirrus.cli.utils import click as utils_click
from click_option_group import RequiredMutuallyExclusiveOptionGroup, optgroup

from cirrus.plugins.management.deployment import (
WORKFLOW_POLL_INTERVAL,
CalledProcessError,
Deployment,
)
from cirrus.plugins.management.deployment import WORKFLOW_POLL_INTERVAL, Deployment
from cirrus.plugins.management.utils.click import (
additional_variables,
silence_templating_errors,
Expand Down
12 changes: 11 additions & 1 deletion src/cirrus/plugins/management/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
from datetime import datetime, timezone
from pathlib import Path
from subprocess import CalledProcessError, check_call
from subprocess import check_call
from time import sleep, time

import backoff
Expand Down Expand Up @@ -321,6 +321,16 @@ def invoke_lambda(self, event, function_name):

return json.load(response["Payload"])

def workflow_event_manager(self):
wfem = None
try:
from cirrus.lib2.events import WorkflowEventManager

wfem = WorkflowEventManager()
except ImportError:
pass
return wfem

def run_workflow(
self,
payload: dict,
Expand Down
22 changes: 14 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,17 @@ def _invoke(cmd, **kwargs):


@pytest.fixture
def basic_payloads(fixtures):
return ProcessPayloads(
process_payloads=[
ProcessPayload(
json.loads(fixtures.joinpath("basic_payload.json").read_text())
)
]
)
def basic_payloads(fixtures, statedb):
payload_list = [
ProcessPayload(json.loads(fixtures.joinpath("basic_payload.json").read_text()))
]
try:
# cirrus-geo >= 0.15.0
payloads = ProcessPayloads(process_payloads=payload_list, statedb=statedb)
except TypeError as te:
# cirrus-geo < 0.15.0
if "unexpected keyword argument 'statedb'" in te.args[0]:
payloads = ProcessPayloads(process_payloads=payload_list)
else:
raise
return payloads
11 changes: 9 additions & 2 deletions tests/test_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,18 @@ def test_manage_get_execution_by_payload_id(deployment, basic_payloads, statedb)
"""
current_env = deepcopy(os.environ) # stash env
deployment.set_env()
basic_payloads.process()

############
# Handle cirrus-geo before WorkflowEventManager (0.15.0)
wfem = deployment.workflow_event_manager()
proc_args = [] if wfem is None else [wfem]
############

basic_payloads.process(*proc_args)
pid = basic_payloads[0]["id"]
sfn_exe1 = deployment.get_execution_by_payload_id(pid)
statedb.set_aborted(pid, execution_arn=sfn_exe1["executionArn"])
basic_payloads.process()
basic_payloads.process(*proc_args)
sfn_exe2 = deployment.get_execution_by_payload_id(pid)
assert sfn_exe1["executionArn"] != sfn_exe2["executionArn"]
os.environ = current_env # pop stash
Expand Down

0 comments on commit 39a8a94

Please sign in to comment.