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: 33 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12']
python-version: ['3.11', '3.12', '3.13', '3.14']

steps:
- uses: actions/checkout@v6
Expand Down Expand Up @@ -127,21 +127,23 @@ jobs:
- test/test_optimizers.py
- test/test_pipeline.py
- test/test_autogen_lib.py
- test/test_snapml.py
- test/test_relational.py
- test/test_category_encoders.py
python-version: ['3.10']
python-version: ['3.13']
setup-target: ['.[full,test]']
include:
- test-case: test/test_core_misc.py
python-version: '3.10'
setup-target: '.[full,test]'
- test-case: test/test_core_misc.py
python-version: '3.11'
setup-target: '.[full,test]'
- test-case: test/test_core_misc.py
python-version: '3.12'
setup-target: '.[full,test]'
- test-case: test/test_core_misc.py
python-version: '3.13'
setup-target: '.[full,test]'
- test-case: test/test_core_misc.py
python-version: '3.14'
setup-target: '.[full,test]'
- test-case: test/test_autogen_lib.py
python-version: '3.11'
setup-target: '.[test]'
Expand All @@ -151,6 +153,10 @@ jobs:
- test-case: test/test_aif360.py
python-version: '3.11'
setup-target: '.[full,test]'
# snapml does not yet support Python 3.13, so pin to 3.12
- test-case: test/test_snapml.py
python-version: '3.12'
setup-target: '.[full,test]'
# - test-case: test/test_relational_sklearn.py
# python-version: '3.11'
# setup-target: '.[full,test]'
Expand All @@ -173,16 +179,17 @@ jobs:
restore-keys: |
${{ runner.os }}-dcache-new3-${{ env.DOWNLOAD_CACHE_DIR }}-
${{ runner.os }}-dcache-new3
- name: Install numpy (pinned for snapml)
if: ${{ matrix.test-case == 'test/test_snapml.py' }}
run: pip install 'numpy>=1.20.1,<=1.26'
- name: Install numpy
if: ${{ matrix.test-case != 'test/test_snapml.py' }}
run: pip install -U numpy
- name: Install dependencies
run: pip install ${{matrix.setup-target}}
# - name: Install deps for test_relational_sklearn
# if: ${{ matrix.test-case == 'test/test_relational_sklearn.py' }}
# run: pip install 'scikit-learn>=1.0'
- name: Install deps for test_snapml
if: ${{ matrix.test-case == 'test/test_snapml.py' }}
run: pip install 'numpy>=1.20.1,<=1.26'
- name: pip list packages
run: pip list
- name: show pip dependencies
Expand Down Expand Up @@ -214,17 +221,20 @@ jobs:
- test/test_pipeline.py
- test/test_relational.py
- test/test_category_encoders.py
python-version: ['3.10', '3.11', '3.12']
python-version: ['3.11', '3.12', '3.13']
setup-target: ['.[full,test]']
include:
- test-case: test/test_core_transformers.py
python-version: '3.10'
python-version: '3.11'
setup-target: '.[full,test]'
- test-case: test/test_core_transformers.py
python-version: '3.10'
python-version: '3.12'
setup-target: '.[full,test]'
- test-case: test/test_core_transformers.py
python-version: '3.11'
python-version: '3.13'
setup-target: '.[full,test]'
- test-case: test/test_core_transformers.py
python-version: '3.14'
setup-target: '.[full,test]'
- test-case: test/test_autogen_lib.py
python-version: '3.11'
Expand All @@ -239,10 +249,10 @@ jobs:
# python-version: '3.11'
# setup-target: '.[full,test]'
- test-case: test/test_snapml.py
python-version: '3.10'
python-version: '3.11'
setup-target: '.[full,test]'
- test-case: test/test_snapml.py
python-version: '3.11'
python-version: '3.12'
setup-target: '.[full,test]'

steps:
Expand All @@ -263,16 +273,17 @@ jobs:
restore-keys: |
${{ runner.os }}-dcache-new3-${{ env.DOWNLOAD_CACHE_DIR }}-
${{ runner.os }}-dcache-new3
- name: Install numpy (pinned for snapml)
if: ${{ matrix.test-case == 'test/test_snapml.py' }}
run: pip install 'numpy>=1.20.1,<=1.26'
- name: Install numpy
if: ${{ matrix.test-case != 'test/test_snapml.py' }}
run: pip install -U numpy
- name: Install dependencies
run: pip install ${{matrix.setup-target}}
# - name: Install deps for test_relational_sklearn
# if: ${{ matrix.test-case == 'test/test_relational_sklearn.py' }}
# run: pip install 'scikit-learn>=1.0'
- name: Install deps for test_snapml
if: ${{ matrix.test-case == 'test/test_snapml.py' }}
run: pip install 'numpy>=1.20.1,<=1.26'
- name: pip list packages
run: pip list
- name: show pip dependencies
Expand All @@ -293,7 +304,7 @@ jobs:
- test/test_core_classifiers.py
- test/test_core_regressors.py
- test/test_core_transformers.py
python-version: ['3.10', '3.11', '3.12']
python-version: ['3.11', '3.12', '3.13', '3.14']
setup-target: ['.']
steps:
- uses: actions/checkout@v6
Expand Down Expand Up @@ -405,7 +416,7 @@ jobs:
- demo_
- docs_
- talk_
python-version: ['3.10', '3.11', '3.12']
python-version: ['3.11', '3.12', '3.13']
setup-target: ['.[full,test]']
test-case: ['test/test_notebooks.py']
dir: ['examples']
Expand All @@ -422,12 +433,12 @@ jobs:
test-case: 'test/test_notebooks.py'
nbexcludes: '02_total.ipynb 08_newops.ipynb'
- dir: 'examples/kdd22'
python-version: '3.10'
python-version: '3.12'
setup-target: '.[tutorial,test]'
test-case: 'test/test_notebooks.py'
nbexcludes: '08_newops.ipynb'
- dir: 'examples/kdd22'
python-version: '3.11'
python-version: '3.13'
setup-target: '.[tutorial,test]'
test-case: 'test/test_notebooks.py'
nbexcludes: '08_newops.ipynb'
Expand Down
2 changes: 0 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ Operator libraries
.. _`PyTorch`: https://pytorch.org/
.. _`lale.lib.spacy`: modules/lale.lib.spacy.html#module-lale.lib.spacy
.. _`spaCy`: https://spacy.io/
.. _`lale.lib.tensorflow`: modules/lale.lib.tensorflow.html#module-lale.lib.tensorflow
.. _`TensorFlow`: https://www.tensorflow.org/
.. _`lale.lib.xgboost`: modules/lale.lib.xgboost.html#module-lale.lib.xgboost
.. _`XGBoost`: https://xgboost.readthedocs.io/en/latest/python/python_api.html

Expand Down
20 changes: 16 additions & 4 deletions lale/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@
import ast # see also https://greentreesnakes.readthedocs.io/
import pprint
import typing
import warnings as _warnings
from copy import deepcopy
from typing import Any, Dict, Literal, Optional, Union, overload

AstLits = (ast.Num, ast.Str, ast.List, ast.Tuple, ast.Set, ast.Dict, ast.Constant)
AstLit = Union[ast.Num, ast.Str, ast.List, ast.Tuple, ast.Set, ast.Dict, ast.Constant]
with _warnings.catch_warnings():
_warnings.simplefilter("ignore", DeprecationWarning)
_ast_Num = getattr(ast, "Num", None)
_ast_Str = getattr(ast, "Str", None)
del _warnings
_legacy_ast_lits = tuple(t for t in [_ast_Num, _ast_Str] if t is not None)
AstLits = (*_legacy_ast_lits, ast.List, ast.Tuple, ast.Set, ast.Dict, ast.Constant)
AstLit = Union[ast.List, ast.Tuple, ast.Set, ast.Dict, ast.Constant]
AstExprs = (
*AstLits,
ast.Name,
Expand Down Expand Up @@ -594,8 +601,13 @@ def _it_column(expr):
return v
elif isinstance(v, ast.Constant):
return v.value
elif isinstance(v, ast.Str):
return v.s
elif (
_ast_Str is not None
and isinstance( # pylint: disable=isinstance-second-argument-not-valid-type
v, _ast_Str
)
):
return v.s # type: ignore[attr-defined]
else:
raise ValueError(
f"Illegal {ast.unparse(expr)}. Only the access to `it` is supported"
Expand Down
8 changes: 4 additions & 4 deletions lale/lib/rasl/_eval_pandas_df.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ def __init__(self, X):
self.result = None
self.df = X

def visit_Num(self, node: ast.Num):
self.result = node.n
def visit_Num(self, node: "ast.Num"): # type: ignore[attr-defined]
self.result = node.n # type: ignore[attr-defined]

def visit_Str(self, node: ast.Str):
self.result = node.s
def visit_Str(self, node: "ast.Str"): # type: ignore[attr-defined]
self.result = node.s # type: ignore[attr-defined]

def visit_Constant(self, node: ast.Constant):
self.result = node.value
Expand Down
13 changes: 10 additions & 3 deletions lale/lib/rasl/orderby.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import ast
from typing import List, Tuple
from typing import List, Optional, Tuple, Type

import lale.docstrings
import lale.operators
Expand All @@ -25,6 +25,8 @@
_is_spark_df,
)

_ast_Str: Optional[Type] = getattr(ast, "Str", None)


class _OrderByImpl:
def __init__(self, by=None):
Expand Down Expand Up @@ -71,8 +73,13 @@ def _get_order_key(self, expr_to_parse) -> Tuple[str, bool]:
col = str(arg.id) # type: ignore
elif hasattr(ast, "Constant") and isinstance(arg, ast.Constant):
col = str(arg.value) # type: ignore
elif hasattr(ast, "Str") and isinstance(arg, ast.Str):
col = str(arg.s)
elif (
_ast_Str is not None
and isinstance( # pylint: disable=isinstance-second-argument-not-valid-type
arg, _ast_Str
)
):
col = str(arg.s) # type: ignore[attr-defined]
elif _is_ast_subscript(arg):
col = str(arg.slice.value.s) # type: ignore
elif _is_ast_attribute(arg):
Expand Down
5 changes: 1 addition & 4 deletions lale/lib/rasl/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ def validate_hyperparams(cls, table: Optional[Expr] = None, X=None, **hyperparam
if isinstance(base, ast.Name) and base.id == "it":
if isinstance(table.expr, ast.Subscript):
sub = table.expr.slice
if isinstance(sub, ast.Constant) or (
isinstance(sub, ast.Index)
and isinstance(getattr(sub, "value", None), ast.Str)
):
if isinstance(sub, ast.Constant):
return
else:
return
Expand Down
2 changes: 1 addition & 1 deletion lale/lib/snapml/snap_linear_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import lale.operators

try:
from snapml import LinearRegression as Base
from snapml import LinearRegression as Base # type: ignore[attr-defined]
except ImportError:
Base = None

Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: Software Development",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
Expand Down Expand Up @@ -63,7 +65,7 @@ full = [
"lightgbm<4.7.0",
"snapml>=1.7.0rc3,<1.18.0; python_version < '3.13'",
"liac-arff>=2.4.0",
"tensorflow>=2.4.0",
"tensorflow>=2.4.0; python_version < '3.14'",
"numba",
"aif360>=0.5.0",
"torch>=1.0",
Expand All @@ -80,7 +82,6 @@ test = [
"ipython<8.8.0",
"jupyter",
"graphviz",
"lxml<5.2.0",
"sphinx>=5.0.0",
"sphinx_rtd_theme>=0.5.2",
"docutils<0.17",
Expand Down
10 changes: 10 additions & 0 deletions test/test_json_pretty_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
import lale.operators
import lale.pretty_print

try:
import snapml as _snapml_check # type: ignore[import-untyped] # noqa: F401

snapml_available = True
del _snapml_check
except ImportError:
snapml_available = False


class TestToGraphviz(unittest.TestCase):
def test_with_operator_choice(self):
Expand Down Expand Up @@ -666,6 +674,7 @@ def test_fairness_info(self):
pipeline = disparate_impact_remover >> KNeighborsClassifier()"""
self._roundtrip(expected, pipeline.pretty_print())

@unittest.skipUnless(snapml_available, "snapml is not installed")
def test_snap_logistic_regression_1(self):
# force printing arguments via "transient": "alwaysPrint", case True
from lale.lib.snapml import SnapLogisticRegression
Expand All @@ -678,6 +687,7 @@ def test_snap_logistic_regression_1(self):
pipeline = SnapLogisticRegression(fit_intercept=True, normalize=True)"""
self._roundtrip(expected, lale.pretty_print.to_string(pipeline))

@unittest.skipUnless(snapml_available, "snapml is not installed")
def test_snap_logistic_regression_2(self):
# force printing arguments via "transient": "alwaysPrint", case False
from lale.lib.snapml import SnapLogisticRegression
Expand Down
51 changes: 0 additions & 51 deletions test/test_nlp_operators.py

This file was deleted.

Loading