Skip to content

improve project structure #6

New issue

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

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

Already on ? Sign in to your account

Merged
merged 1 commit into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on .

16 changes: 7 additions & 9 deletions README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,16 +14,14 @@ With the SDK you can:

- Python 3 required

- pipenv required `pip install pipenv`

```
pipenv install
python setup.py pytest
```

If you get issues about missing modules:
pipenv shell

```
pip3 install jsonschema
pip3 install pyyaml
python setup.py pytest
```

## **WIP** Programmatically build workflow definitions
Expand DownExpand Up@@ -69,7 +67,7 @@ functions:
workflow = Workflow.from_source(swf_content)
```

You can see a full example in the [test_workflow.py](./tests/test_workflow.py) file
You can see a full example in the [test_workflow.py](tests/serverlessworkflow/sdk/test_workflow.py) file


### Parse workflow to JSON / YAML
Expand All@@ -88,7 +86,7 @@ print(workflow.to_json())
print(workflow.to_yaml())
```

You can see a full example in the [test_workflow.py](./tests/test_workflow.py) file
You can see a full example in the [test_workflow.py](tests/serverlessworkflow/sdk/test_workflow.py) file


## Validate workflow definitions
Expand All@@ -108,4 +106,4 @@ WorkflowValidator(Workflow(workflow)).validate()
```
The `validate` method will raise an exception if the provided workflow does not complaint specification.

You can see a full example in the [test_workflow_validator](./tests/test_workflow_validator.py) file
You can see a full example in the [test_workflow_validator](tests/serverlessworkflow/sdk/test_workflow_validator.py) file
File renamed without changes.
Empty file.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
from serverlessworkflow_sdk.state import State
from serverlessworkflow.sdk.state import State


class InjectState(State):
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
from serverlessworkflow_sdk.action import Action
from serverlessworkflow_sdk.state import State
from serverlessworkflow.sdk.action import Action
from serverlessworkflow.sdk.state import State


class OperationState(State):
Expand Down
File renamed without changes.
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,9 @@

import yaml

from serverlessworkflow_sdk.inject_state import InjectState
from serverlessworkflow_sdk.operation_state import OperationState
from serverlessworkflow_sdk.state import State
from serverlessworkflow.sdk.inject_state import InjectState
from serverlessworkflow.sdk.operation_state import OperationState
from serverlessworkflow.sdk.state import State


def is_inject_state(state: State):
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
import json
import requests
from jsonschema.validators import validate
from serverlessworkflow_sdk.workflow import Workflow

from serverlessworkflow.sdk.workflow import Workflow


class WorkflowValidator:
Expand Down
16 changes: 12 additions & 4 deletions setup.py
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
from setuptools import find_packages, setup

with open("README.md", "r") as readme_file:
readme = readme_file.read()

setup(
name='serverlessworkflow_sdk',
packages=find_packages(include=['serverlessworkflow_sdk']),
name='serverlessworkflow.sdk',
packages=find_packages(include=['serverlessworkflow', 'serverlessworkflow.sdk']),
version='0.1.0',
description='Serverless Workflow Specification - Python SDK',
long_description=readme,
long_description_content_type="text/markdown",
url="https://serverlessworkflow.io/",
author='Serverless Workflow Contributors',
license='http://www.apache.org/licenses/LICENSE-2.0.txt',
install_requires=[],
install_requires=['pyyaml==6.0', "jsonschema==4.4.0", "requests"],
setup_requires=['pytest-runner'],
tests_require=['pytest'],
test_suite='tests',
)

)
Empty file.
Empty file.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
import os
import unittest

from serverlessworkflow_sdk.action import Action
from serverlessworkflow_sdk.workflow import Workflow
from serverlessworkflow.sdk.action import Action
from serverlessworkflow.sdk.workflow import Workflow


class TestWorkflow(unittest.TestCase):
Expand Down
File renamed without changes.
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,14 +5,14 @@

from jsonschema.exceptions import ValidationError

from serverlessworkflow_sdk.workflow import Workflow
from serverlessworkflow_sdk.workflow_validator import WorkflowValidator
from serverlessworkflow.sdk.workflow import Workflow
from serverlessworkflow.sdk.workflow_validator import WorkflowValidator


class TestWorkflowValidator(unittest.TestCase):

def test_validate_examples(self):
examples_dir = os.path.join(os.path.dirname(__file__), 'examples')
examples_dir = os.path.join(os.path.dirname(__file__), '../../examples')
examples = listdir(examples_dir)
self.assertEqual(len(examples), 9)

Expand All@@ -22,7 +22,7 @@ def test_validate_examples(self):
WorkflowValidator(Workflow(**swf_file_content)).validate()

def test_invalid_wf(self):
wf_file = os.path.join(os.path.dirname(__file__), 'examples', 'applicantrequest.json')
wf_file = os.path.join(os.path.dirname(__file__), '../../examples', 'applicantrequest.json')

with open(wf_file, "r") as swf_file:
swf_content = swf_file.read()
Expand Down