Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DS-6428 upgrade garcon to boto3 #17

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
94b1345
Update setup.py
xethorn Jan 6, 2018
df028d6
Added tox
Bakuutin Jan 1, 2018
9d43c8d
Merge pull request #84 from theorchard/python36
xethorn May 20, 2018
e5ba08f
Migrate from boto2 to boto3.
xethorn Jul 16, 2018
e042196
Refactor: split requirements in two files, one for library and one fo…
xethorn Jul 22, 2018
9592857
Add Github Workflows.
xethorn May 2, 2020
f1633ab
Add on_exception to run() activity method if fail() method fails (#90)
Emersin May 6, 2020
dee1b3d
Add workflow to publish to pypi.
xethorn May 9, 2020
179de5a
Merge pull request #92 from xethorn/xethorn/20-may-add-workflow-to-pu…
xethorn May 9, 2020
27138fe
Create 1.0.0 alpha release
xethorn May 9, 2020
845d419
Merge pull request #93 from xethorn/xethorn/20-may-create-alpha-release
xethorn May 9, 2020
e5db053
Remove support for python 2.7.
xethorn May 10, 2020
efef1a4
Merge pull request #94 from xethorn/xethorn/20-may-remove-python27
xethorn May 10, 2020
5ae3839
Issue 1.0.0 Alpha 2
xethorn May 10, 2020
3c2b455
Merge pull request #95 from xethorn/xethorn/20-may-issue-1.0.0a2
xethorn May 10, 2020
784ec35
Added log.GarconLogger as ancestor for ActivityExecution, fixed heart…
Emersin Jun 9, 2020
39f4297
Update testing.yml
xethorn Jun 9, 2020
ae8427c
Merge pull request #97 from xethorn/xethorn/20-june-add-support-for-r…
xethorn Jun 9, 2020
6177d4a
Merge pull request #96 from Emersin/fix-for-ActivityExecution
xethorn Jun 9, 2020
c46e85e
Update setup.py
xethorn Jun 9, 2020
8464ba7
Update setup.py
xethorn Jun 9, 2020
c2bd230
Merge pull request #99 from xethorn/xethorn/20-june-bump-version
xethorn Jun 9, 2020
be5ae15
Merge pull request #98 from xethorn/xethorn/20-june-bump-version-1
xethorn Jun 9, 2020
40f7e9d
Update setup.py
xethorn Jun 12, 2020
1d446b4
Fix for decider param
Emersin Jun 19, 2020
22ac2a2
Merge pull request #100 from Emersin/fix-for-decider-param
xethorn Jun 19, 2020
1b1a490
v1.0.1
xethorn Jun 19, 2020
ec297af
Merge pull request #101 from xethorn/xethorn/20-june-1.0.1
xethorn Jun 19, 2020
52395dc
Fixed another decider param
Emersin Jun 19, 2020
6730d50
Merge pull request #102 from Emersin/fix-for-decider-param
xethorn Jun 20, 2020
586eebe
Update setup.py
xethorn Jun 20, 2020
80a3ef5
Update testing.yml
xethorn Jan 5, 2021
e44db30
Update README.rst
xethorn Jan 5, 2021
ece65a3
Create codeql-analysis.yml
xethorn May 2, 2021
280c119
Merge pull request #103 from xethorn/xethorn/2021/may/add-codeql
xethorn May 2, 2021
5bd4b3b
Update example in README
xethorn May 9, 2021
6eae7e6
Merge pull request #104 from xethorn/xethorn/21-may-update-readme
xethorn May 9, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '39 1 * * 5'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
28 changes: 28 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Upload Python Package

on:
release:
types: [created]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
36 changes: 36 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Build

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-tests.txt
- name: Lint with flake8
run: |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: |
pytest --cov=.
coveralls
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

100 changes: 55 additions & 45 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
|Build Status| |Coverage Status|
|BuildStatus| |Downloads| |CoverageStatus|

Lightweight library for AWS SWF.

Expand All @@ -10,8 +10,8 @@ Lightweight library for AWS SWF.
Requirements
~~~~~~~~~~~~

- Python 2.7, 3.4 (tested)
- Boto 2.34.0 (tested)
- Python 3.5, 3.6, 3.7, 3.8 (tested)
- Boto3 (tested)

Goal
~~~~
Expand All @@ -25,47 +25,38 @@ case, you might want to use directly boto.
Code sample
~~~~~~~~~~~

The code sample shows a workflow that has 4 activities. It starts with
activity\_1, which after being completed schedule activity\_2 and
activity\_3 to be ran in parallel. The workflow ends after the
completion of activity\_4 which requires activity\_2 and activity\_3 to
be completed.
The code sample shows a workflow where a user enters a coffee shop, orders
a coffee and a chocolate chip cookie. All ordered items are prepared and
completed, the user pays the order, receives the ordered items, then leave
the shop.

.. code:: python

from __future__ import print_function

from garcon import activity
from garcon import runner


domain = 'dev'
name = 'workflow_sample'
create = activity.create(domain, name)

test_activity_1 = create(
name='activity_1',
run=runner.Sync(
lambda activity, context: print('activity_1')))
The code below represents the workflow decider. For the full code sample,
see the `example`_.

test_activity_2 = create(
name='activity_2',
requires=[test_activity_1],
run=runner.Async(
lambda activity, context: print('activity_2_task_1'),
lambda activity, context: print('activity_2_task_2')))
.. code:: python

test_activity_3 = create(
name='activity_3',
requires=[test_activity_1],
run=runner.Sync(
lambda activity, context: print('activity_3')))
enter = schedule('enter', self.create_enter_coffee_activity)
enter.wait()

total = 0
for item in ['coffee', 'chocolate_chip_cookie']:
activity_name = 'order_{item}'.format(item=item)
activity = schedule(activity_name,
self.create_order_activity,
input={'item': item})
total += activity.result.get('price')

pay_activity = schedule(
'pay', self.create_payment_activity,
input={'total': total})

get_order = schedule('get_order', self.create_get_order_activity)

# Waiting for paying and getting the order to complete before
# we let the user leave the coffee shop.
pay_activity.wait(), get_order.wait()
schedule('leave_coffee_shop', self.create_leave_coffee_shop)

test_activity_4 = create(
name='activity_4',
requires=[test_activity_3, test_activity_2],
run=runner.Sync(
lambda activity, context: print('activity_4')))

Application architecture
~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -82,19 +73,38 @@ Application architecture
│ └── s3.py # Task that focuses on s3 files.
└── task_example.py # Your different tasks.

Trusted by
~~~~~~~~~~

|The Orchard| |Sony Music| |DataArt|

Contributors
~~~~~~~~~~~~

- Michael Ortali
- Michael Ortali (Author)
- Adam Griffiths
- Raphael Antonmattei
- John Penner

.. _xethorn: github.com/xethorn
.. _rantonmattei: github.com/rantonmattei
.. _someboredkiddo: github.com/someboredkiddo
.. _example: https://github.com/xethorn/garcon/tree/master/example/custom_decider

.. |BuildStatus| image:: https://github.com/xethorn/garcon/workflows/Build/badge.svg
:target: https://github.com/xethorn/garcon/actions?query=workflow%3ABuild+branch%3Amaster

.. |Downloads| image:: https://img.shields.io/pypi/dm/garcon.svg
:target: https://coveralls.io/r/xethorn/garcon?branch=master

.. |CoverageStatus| image:: https://coveralls.io/repos/xethorn/garcon/badge.svg?branch=master
:target: https://coveralls.io/r/xethorn/garcon?branch=master

.. |The Orchard| image:: https://media-exp1.licdn.com/dms/image/C4E0BAQGi7o5g9l4JWg/company-logo_200_200/0/1519855981606?e=2159024400&v=beta&t=WBe-gOK2b30vUTGKbA025i9NFVDyOrS4Fotx9fMEZWo
:target: https://theorchard.com

.. |Build Status| image:: https://travis-ci.org/xethorn/garcon.svg
:target: https://travis-ci.org/xethorn/garcon
.. |Coverage Status| image:: https://coveralls.io/repos/xethorn/garcon/badge.svg?branch=master
:target: https://coveralls.io/r/xethorn/garcon?branch=master
.. |Sony Music| image:: https://media-exp1.licdn.com/dms/image/C4D0BAQE9rvU-3ig-jg/company-logo_200_200/0/1604099587507?e=2159024400&v=beta&t=eAAubphf_fI-5GEb0ak1QnmtRHmc8466Qj4sGrCsWYc
:target: https://www.sonymusic.com/

.. |DataArt| image:: https://media-exp1.licdn.com/dms/image/C4E0BAQGRi6OIlNQG8Q/company-logo_200_200/0/1519856519357?e=2159024400&v=beta&t=oi6HQpzoeTKA082s-8Ft75vGTvAkEp4VHRyMLeOHXoo
:target: https://www.dataart.com/
4 changes: 1 addition & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Lightweight library for AWS SWF.
Requirements
------------

* Python 2.7, 3.4 (tested)
* Python 3.5, 3.6, 3.7, 3.8 (tested)
* Boto 2.34.0 (tested)


Expand All @@ -20,8 +20,6 @@ Code sample

The code sample shows a workflow that has 4 activities. It starts with activity_1, which after being completed schedule activity_2 and activity_3 to be ran in parallel. The workflow ends after the completion of activity_4 which requires activity_2 and activity_3 to be completed::

from __future__ import print_function

from garcon import activity
from garcon import runner

Expand Down
22 changes: 15 additions & 7 deletions example/custom_decider/run.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
from garcon import activity
from garcon import decider
from threading import Thread
import boto.swf.layer2 as swf
import time

import boto3
import workflow

# Initiate the workflow on the dev domain and custom_decider name.
flow = workflow.Workflow('dev', 'custom_decider')
deciderworker = decider.DeciderWorker(flow)
client = boto3.client('swf', region_name='us-east-1')
workflow = workflow.Workflow(client, 'dev', 'custom_decider')
deciderworker = decider.DeciderWorker(workflow)

# swf.WorkflowType(
# name=flow.name, domain=flow.domain,
# version='1.0', task_list=flow.name).start()
client.start_workflow_execution(
domain=workflow.domain,
workflowId='unique-workflow-identifier',
workflowType=dict(
name=workflow.name,
version='1.0'),
executionStartToCloseTimeout='3600',
taskStartToCloseTimeout='3600',
childPolicy='TERMINATE',
taskList=dict(name=workflow.name))

Thread(target=activity.ActivityWorker(flow).run).start()
Thread(target=activity.ActivityWorker(workflow).run).start()
while(True):
deciderworker.run()
time.sleep(1)
22 changes: 11 additions & 11 deletions example/custom_decider/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,20 @@
Workflow:
1. Enter in the coffee shop.
2. Order.
2.1 Chocolate chip cookie.
2.2 Coffee.
2.1 Coffee.
2.2 Chocolate chip cookie.
3. Finalize the order (any of the activites below can be done in any order)
3.1 Pays.
3.2 Get the order.
4. Leave the coffee shop.

Result:

entering coffee shop
ordering: coffee
ordering: chocolate_chip_cookie
pay $6.98
get order
leaving the coffee shop
entering coffee shop
ordering: coffee
ordering: chocolate_chip_cookie
pay $6.98
get order
leaving the coffee shop
"""

from garcon import activity
Expand All @@ -33,7 +32,7 @@

class Workflow:

def __init__(self, domain, name):
def __init__(self, client, domain, name):
"""Create the workflow.

Args:
Expand All @@ -42,7 +41,8 @@ def __init__(self, domain, name):
"""
self.name = name
self.domain = domain
self.create_activity = activity.create(domain, name)
self.client = client
self.create_activity = activity.create(client, domain, name)

def decider(self, schedule, context=None):
"""Custom deciders.
Expand Down
Loading