Skip to content
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
55 changes: 55 additions & 0 deletions .github/workflows/lint-and-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Starfish testing workflow

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test-integration:
runs-on: ubuntu-latest

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

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'

- name: Load cached Poetry installation
uses: actions/cache@v3
with:
path: ~/.local
key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}

- name: Load cached venv
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-python-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Set Locale
run: |
sudo locale-gen "en_US.UTF-8"
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export TELEMETRY_ENABLED=false

- name: Install dependencies
run: |
pip install poetry
poetry install --with dev

# - name: Run ruff
# run: |
# poetry run ruff check . --output-format=github
# poetry run ruff format . --check

- name: Run tests with coverage
run: |
poetry run pytest --cov='src' --cov-report=html --cov-fail-under=20 tests/
25 changes: 25 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
repos:
# - repo: local
# hooks:
# - id: pytest
# name: Run pytest
# entry: poetry run pytest tests/
# language: system
# types: [python]
# pass_filenames: false
# always_run: true

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.8.6
hooks:
# Run the linter.
# - id: ruff
# args: [ --fix ]
# types: [python]
# Run the formatter.
- id: ruff-format
# args: [ --fix ]
#run even when no Python files are staged
#always_run: true
types: [python]
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
lint:
@echo "Running Linter (Ruff)..."
isort tests/ starfish/ examples
# poetry run ruff check tests starfish examples --fix
poetry run ruff format tests starfish examples
poetry run isort tests/ src/ examples --check-only || poetry run isort tests/ src/ examples
poetry run ruff check src examples --fix --unsafe-fixes --exit-zero
poetry run ruff format src examples --check || poetry run ruff format src examples

test:
poetry run pytest tests/
poetry run pytest tests/

install:
@echo "Installing dependencies..."
poetry install
poetry run pre-commit install --install-hooks


20 changes: 7 additions & 13 deletions examples/datafactor_input_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,11 @@ def workflow(city_name, num_records_per_city):
data = workflow.run(city_name=["San Francisco", "New York", "Los Angeles"], num_records_per_city=3)


### Use Case 3: data=List[Dict] Only
data = workflow.run(data = [
{'city_name': 'Paris'},
{'city_name': 'Tokyo'}
])
### Use Case 3: data=List[Dict] Only
data = workflow.run(data=[{"city_name": "Paris"}, {"city_name": "Tokyo"}])

### Use Case 4: data=List[Dict] + Broadcast Kwarg
data = workflow.run(data = [
{'city_name': 'Paris'},
{'city_name': 'Tokyo'}
], num_records_per_city = 3)
data = workflow.run(data=[{"city_name": "Paris"}, {"city_name": "Tokyo"}], num_records_per_city=3)


### Use Case 5: data (List[Dict]) + Parallel Kwarg (Matching Lengths)
Expand Down Expand Up @@ -95,22 +89,22 @@ def get_city_info_wf(city_name, region_code, num_records_per_city):

## Invoke sequence
# [
# {'city_name': 'Berlin'},
# {'city_name': 'Berlin'},
# {'city_name': 'Rome'}
# ]

# [
# {'city_name': 'Berlin', 'region_code': 'DE'},
# {'city_name': 'Berlin', 'region_code': 'DE'},
# {'city_name': 'Rome', 'region_code': 'IT'}
# ]

# [
# {'city_name': 'Beijing', 'region_code': 'DE'},
# {'city_name': 'Beijing', 'region_code': 'DE'},
# {'city_name': 'Beijing', 'region_code': 'IT'}
# ]

# [
# {'city_name': 'Beijing', 'region_code': 'DE', 'num_records_per_city': 3},
# {'city_name': 'Beijing', 'region_code': 'DE', 'num_records_per_city': 3},
# {'city_name': 'Beijing', 'region_code': 'IT', 'num_records_per_city': 3}
# ]

Expand Down
Loading