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

feat: adding new node type CompositeActionInput #133

Merged
merged 4 commits into from
Nov 10, 2023
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
13 changes: 12 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ jobs:
prevent: true
fail-on-error: true
allowed-ips: >
3.216.34.172
3.228.146.75
18.206.20.10
18.210.197.188
18.215.138.58
34.194.164.123
34.205.13.154
44.196.175.70
44.205.64.79
52.1.184.176
52.3.144.121
54.165.156.197
Expand Down Expand Up @@ -64,9 +70,15 @@ jobs:
prevent: true
fail-on-error: true
allowed-ips: >
3.216.34.172
3.228.146.75
18.206.20.10
18.210.197.188
18.215.138.58
34.194.164.123
34.205.13.154
44.196.175.70
44.205.64.79
52.1.184.176
52.3.144.121
54.165.156.197
Expand All @@ -85,7 +97,6 @@ jobs:
with:
ref: ${{ github.ref }}


- name: Set up Python
uses: actions/setup-python@v4
with:
Expand Down
23 changes: 21 additions & 2 deletions .github/workflows/test_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ jobs:
fi
exit 0

# A job that runs integration tests in an isolated environment against
# a predefined organization: RavenIntegrationTests
test_raven:
runs-on: ubuntu-latest
steps:
Expand All @@ -65,9 +67,15 @@ jobs:
prevent: true
fail-on-error: true
allowed-ips: >
3.216.34.172
3.228.146.75
18.206.20.10
18.210.197.188
18.215.138.58
34.194.164.123
34.205.13.154
44.196.175.70
44.205.64.79
52.1.184.176
52.3.144.121
54.165.156.197
Expand All @@ -90,6 +98,8 @@ jobs:
run: |
make test-build

# A job for testing the setup process and unit tests of RAVEN against
# different versions of Python
test_raven_package:
runs-on: ubuntu-latest

Expand All @@ -103,9 +113,15 @@ jobs:
prevent: true
fail-on-error: true
allowed-ips: >
3.216.34.172
3.228.146.75
18.206.20.10
18.210.197.188
18.215.138.58
34.194.164.123
34.205.13.154
44.196.175.70
44.205.64.79
52.1.184.176
52.3.144.121
54.165.156.197
Expand Down Expand Up @@ -133,10 +149,13 @@ jobs:
- name: Setup environment
run: make setup

- name: Download Organization
- name: Test Raven
elad-pticha marked this conversation as resolved.
Show resolved Hide resolved
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
raven download org --token $GITHUB_TOKEN --org-name RavenIntegrationTests
raven index
raven report --format json | jq > /dev/null
raven report --format json | jq > /dev/null

- name: Run Unit Tests
run: pytest -v tests/unit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ ipython_config.py

# Local debugging - Run tests outside containers
temp_test_raven.py
temp/

# pyenv
.python-version
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ test-build:
test-run:
@echo "DO NOT USE DIRECTLY; PLEASE USE: make test-build"
@echo "Running Tests..."
@python3 test_raven.py
@pytest -v tests
3 changes: 0 additions & 3 deletions deployment/test.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ COPY Makefile requirements.txt /raven/
COPY src /raven/src
COPY tests /raven/tests

# Move the main test file to the Root directory
RUN mv /raven/tests/test_raven.py /raven/test_raven.py

# Install any needed packages specified in requirements.txt
RUN pip3 install -r requirements.txt

Expand Down
4 changes: 4 additions & 0 deletions src/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,7 @@ def is_url_contains_a_token(url) -> bool:

def str_to_bool(s: str) -> bool:
return bool(int(s))


def raw_str_to_bool(s: str) -> bool:
return True if s == "true" else False
elad-pticha marked this conversation as resolved.
Show resolved Hide resolved
47 changes: 45 additions & 2 deletions src/workflow_components/composite_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from src.common.utils import (
get_dependencies_in_code,
convert_dict_to_list,
raw_str_to_bool,
)
from src.workflow_components.dependency import UsesString, UsesStringType

Expand All @@ -27,6 +28,43 @@ def get_or_create_composite_action(path: str) -> "CompositeAction":
return obj


class CompositeActionInput(GraphObject):
__primarykey__ = "_id"

_id = Property()
name = Property()
elad-pticha marked this conversation as resolved.
Show resolved Hide resolved
default = Property()
description = Property()
required = Property()
elad-pticha marked this conversation as resolved.
Show resolved Hide resolved
url = Property()
path = Property()
action = RelatedTo("CompositeAction")

def __init__(self, _id: str, path: str):
self._id = _id
self.path = path

@staticmethod
def from_dict(obj_dict) -> "CompositeActionInput":
i = CompositeActionInput(
_id=obj_dict["_id"],
path=obj_dict["path"],
)

i.name = obj_dict["name"]
i.url = obj_dict["url"]

if "default" in obj_dict:
i.default = obj_dict["default"]

if "description" in obj_dict:
i.description = obj_dict["description"]

i.required = raw_str_to_bool(obj_dict.get("required", "false"))

return i


class CompositeActionStep(GraphObject):
__primarykey__ = "_id"

Expand Down Expand Up @@ -91,12 +129,12 @@ class CompositeAction(GraphObject):
_id = Property()
name = Property()
path = Property()
inputs = Property()
using = Property()
image = Property()
url = Property()
is_public = Property()

inputs = RelatedTo(CompositeActionInput)
steps = RelatedTo(CompositeActionStep)

def __init__(self, name: Optional[str], path: str):
Expand All @@ -111,7 +149,12 @@ def from_dict(obj_dict) -> "CompositeAction":
ca.url = obj_dict["url"]
ca.is_public = obj_dict["is_public"]
if "inputs" in obj_dict:
ca.inputs = list(obj_dict["inputs"].keys())
for name, input in obj_dict["inputs"].items():
input["_id"] = md5(f"{ca._id}_{name}".encode()).hexdigest()
input["name"] = name
input["url"] = ca.url
input["path"] = ca.path
ca.inputs.add(CompositeActionInput.from_dict(input))

if "runs" in obj_dict:
d_runs = obj_dict["runs"]
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/integration_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@
},
},
]

START_NODE_INDEX = 0
DEST_NODE_INDEX = 2
Loading