Skip to content

Commit

Permalink
IR progress
Browse files Browse the repository at this point in the history
  • Loading branch information
nx10 committed Sep 5, 2024
1 parent 42d858e commit f30e225
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/styx/backend/python/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Python wrapper backend."""

from .core import to_python
from .core import to_python as to_python
2 changes: 1 addition & 1 deletion src/styx/backend/python/constraints.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styx.ir.core as ir
from styx.backend.python.lookup import LookupParam
from styx.backend.python.pycodegen.core import LineBuffer, PyFunc, indent
import styx.ir.core as ir


def _generate_raise_value_err(obj: str, expectation: str, reality: str | None = None) -> LineBuffer:
Expand Down
2 changes: 1 addition & 1 deletion src/styx/backend/python/lookup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styx.ir.core as ir
from styx.backend.python.pycodegen.scope import Scope
from styx.backend.python.pycodegen.utils import python_snakify, python_pascalize
from styx.backend.python.pycodegen.utils import python_pascalize, python_snakify
from styx.backend.python.utils import iter_params_recursively, param_py_type


Expand Down
4 changes: 2 additions & 2 deletions src/styx/frontend/boutiques/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Boutiques frontend"""
"""Boutiques frontend."""

from .core import from_boutiques
from .core import from_boutiques as from_boutiques
5 changes: 1 addition & 4 deletions src/styx/frontend/boutiques/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,6 @@ def _collect_inputs(bt, id_counter):

def from_boutiques(tool: dict, package_name: str) -> ir.Interface:
"""Convert a Boutiques tool to a Styx descriptor."""
if not (tool_name := tool.get("name")):
raise ValueError(f"name is missing for tool '{tool}'")

hash_ = _hash_from_boutiques(tool)

docker: str | None = None
Expand All @@ -463,7 +460,7 @@ def from_boutiques(tool: dict, package_name: str) -> ir.Interface:
uid=f"{hash_}.boutiques",
package=ir.Package(
name=package_name,
version="1.0",
version=tool.get("tool-version"),
docker=docker,
),
command=ir.PStruct(
Expand Down
10 changes: 5 additions & 5 deletions src/styx/ir/core.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import dataclasses
import typing
from abc import ABC
from dataclasses import dataclass
from typing import Any, Generator


@dataclass
Expand Down Expand Up @@ -58,7 +58,7 @@ class IParam(ABC):


class IOptional(ABC):
class SetToNoneAble:
class SetToNoneAble: # noqa
pass

SetToNone = SetToNoneAble()
Expand Down Expand Up @@ -210,7 +210,7 @@ class PBoolListOpt(IBool, IList, IParam, IOptional):
class Carg:
tokens: list[IParam | str] = dataclasses.field(default_factory=list)

def iter_params(self):
def iter_params(self) -> Generator[IParam, Any, None]:
for token in self.tokens:
if isinstance(token, IParam):
yield token
Expand All @@ -220,7 +220,7 @@ def iter_params(self):
class ConditionalGroup:
cargs: list[Carg] = dataclasses.field(default_factory=list)

def iter_params(self):
def iter_params(self) -> Generator[IParam, Any, None]:
for carg in self.cargs:
yield from carg.iter_params()

Expand All @@ -232,7 +232,7 @@ class DStruct:
"""(group (cargs (join str+params))) """
docs: Documentation | None = None

def iter_params(self):
def iter_params(self) -> Generator[IParam, Any, None]:
for group in self.groups:
yield from group.iter_params()

Expand Down
3 changes: 1 addition & 2 deletions src/styx/ir/dyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ def dyn_param(
dyn_type: typing.Literal["int", "float", "str", "file", "bool", "struct", "struct_union"],
dyn_list: bool,
dyn_optional: bool,
**kwargs,
**kwargs, # noqa
) -> ir.IParam:
"""Convenience function that allows dynamic param class creation."""

cls = {
("int", True, True): ir.PIntListOpt,
("int", True, False): ir.PIntList,
Expand Down

0 comments on commit f30e225

Please sign in to comment.