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

assert_that broken with TypeError on beam 2.50.0 conda distro (but not pip) #67

Closed
1 task done
cisaacstern opened this issue Sep 7, 2023 · 3 comments · Fixed by #68
Closed
1 task done

assert_that broken with TypeError on beam 2.50.0 conda distro (but not pip) #67

cisaacstern opened this issue Sep 7, 2023 · 3 comments · Fixed by #68
Labels
bug Something isn't working

Comments

@cisaacstern
Copy link

cisaacstern commented Sep 7, 2023

Solution to issue cannot be found in the documentation.

  • I checked the documentation.

Issue

Starting from beam 2.50.0, assert_that from from apache_beam.testing.util is broken only on the conda disto (not pip), raising:

apache_beam/runners/common.py:491: in apache_beam.runners.common.DoFnInvoker.create_invoker
>   ???
TypeError: Argument 'input_args' has incorrect type (expected list, got tuple)
Full trace
/usr/share/miniconda3/envs/test/lib/python3.11/site-packages/apache_beam/pipeline.py:600: in __exit__
    self.result = self.run()
/usr/share/miniconda3/envs/test/lib/python3.11/site-packages/apache_beam/testing/test_pipeline.py:112: in run
    result = super().run(
/usr/share/miniconda3/envs/test/lib/python3.11/site-packages/apache_beam/pipeline.py:553: in run
    self._options).run(False)
/usr/share/miniconda3/envs/test/lib/python3.11/site-packages/apache_beam/pipeline.py:577: in run
    return self.runner.run_pipeline(self, self._options)
/usr/share/miniconda3/envs/test/lib/python3.11/site-packages/apache_beam/runners/direct/direct_runner.py:128: in run_pipeline
    return runner.run_pipeline(pipeline, options)
/usr/share/miniconda3/envs/test/lib/python3.11/site-packages/apache_beam/runners/portability/fn_api_runner/fn_runner.py:202: in run_pipeline
    self._latest_run_result = self.run_via_runner_api(
/usr/share/miniconda3/envs/test/lib/python3.11/site-packages/apache_beam/runners/portability/fn_api_runner/fn_runner.py:224: in run_via_runner_api
    return self.run_stages(stage_context, stages)
/usr/share/miniconda3/envs/test/lib/python3.11/site-packages/apache_beam/runners/portability/fn_api_runner/fn_runner.py:455: in run_stages
    bundle_results = self._execute_bundle(
/usr/share/miniconda3/envs/test/lib/python3.11/site-packages/apache_beam/runners/portability/fn_api_runner/fn_runner.py:783: in _execute_bundle
    self._run_bundle(
/usr/share/miniconda3/envs/test/lib/python3.11/site-packages/apache_beam/runners/portability/fn_api_runner/fn_runner.py:1020: in _run_bundle
    result, splits = bundle_manager.process_bundle(
/usr/share/miniconda3/envs/test/lib/python3.11/site-packages/apache_beam/runners/portability/fn_api_runner/fn_runner.py:1356: in process_bundle
    result_future = self._worker_handler.control_conn.push(process_bundle_req)
/usr/share/miniconda3/envs/test/lib/python3.11/site-packages/apache_beam/runners/portability/fn_api_runner/worker_handlers.py:379: in push
    response = self.worker.do_instruction(request)
/usr/share/miniconda3/envs/test/lib/python3.11/site-packages/apache_beam/runners/worker/sdk_worker.py:625: in do_instruction
    return getattr(self, request_type)(
/usr/share/miniconda3/envs/test/lib/python3.11/site-packages/apache_beam/runners/worker/sdk_worker.py:656: in process_bundle
    bundle_processor = self.bundle_processor_cache.get(
/usr/share/miniconda3/envs/test/lib/python3.11/site-packages/apache_beam/runners/worker/sdk_worker.py:487: in get
    processor = bundle_processor.BundleProcessor(
/usr/share/miniconda3/envs/test/lib/python3.11/site-packages/apache_beam/runners/worker/bundle_processor.py:914: in __init__
    op.setup(self.data_sampler)
apache_beam/runners/worker/operations.py:875: in apache_beam.runners.worker.operations.DoOperation.setup
    ???
apache_beam/runners/worker/operations.py:913: in apache_beam.runners.worker.operations.DoOperation.setup
    ???
apache_beam/runners/common.py:1410: in apache_beam.runners.common.DoFnRunner.__init__
    ???
apache_beam/runners/common.py:491: in apache_beam.runners.common.DoFnInvoker.create_invoker
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   TypeError: Argument 'input_args' has incorrect type (expected list, got tuple)

I have replicated this error with the MRE in cisaacstern/beam2.50.0-assert-that-bug#1, with the relevant trace here.

For visibility, here is the test module that PR runs:

import apache_beam as beam
from apache_beam.testing.test_pipeline import TestPipeline
from apache_beam.testing.util import assert_that


def expected_nums():
   def _expected_nums(actual):
       assert actual[0] == 0
       assert actual[1] == 1

   return _expected_nums


def test_pipeline_without_assert_that():
   with TestPipeline() as p:
       _ = p | beam.Create([0, 1])


def test_assert_that():
   with TestPipeline() as p:
       nums = p | beam.Create([0, 1])
       assert_that(nums, expected_nums())

As the linked PR demonstrates, test_assert_that in this module fails with TypeError with beam 2.50.0 installed from conda, but not pip.

This issue began in 2.50.0 as the PR also demonstrates that this test module passes with beam 2.49.0 installed from either conda or pip.

Installed packages

Copied from https://github.com/cisaacstern/beam2.50.0-assert-that-bug/actions/runs/6103506815/job/16564018052?pr=1#step:6:39

# packages in environment at /usr/share/miniconda3/envs/test:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
anyio                     4.0.0              pyhd8ed1ab_0    conda-forge
apache-beam               2.50.0          py311h459d7ec_0    conda-forge
atk-1.0                   2.38.0               hd4edc92_1    conda-forge
aws-c-auth                0.7.3                he2921ad_3    conda-forge
aws-c-cal                 0.6.2                hc309b26_0    conda-forge
aws-c-common              0.9.0                hd590300_0    conda-forge
aws-c-compression         0.2.17               h4d4d85c_2    conda-forge
libutf8proc               2.8.0                h166bdaf_0    conda-forge
libuuid                   2.38.1               h0b41bf4_0    conda-forge
libwebp                   1.3.1                hbf2b3c1_0    conda-forge
libwebp-base              1.3.1                hd590300_0    conda-forge
libxcb                    1.15                 h0b41bf4_0    conda-forge
libxml2                   2.11.5               h232c23b_1    conda-forge
libzlib                   1.2.13               hd590300_5    conda-forge
lz4-c                     1.9.4                hcb278e6_0    conda-forge
ncurses                   6.4                  hcb278e6_0    conda-forge
numpy                     1.24.4          py311h64a7726_0    conda-forge
objsize                   0.6.1              pyhd8ed1ab_0    conda-forge
openssl                   3.1.2                hd590300_0    conda-forge
orc                       1.9.0                h385abfd_1    conda-forge
orjson                    3.9.5           py311h34b1e23_0    conda-forge
packaging                 23.1                     pypi_0    pypi
pandas                    2.1.0           py311h320fe9a_0    conda-forge
pango                     1.50.14              ha41ecd1_2    conda-forge
pcre2                     10.40                hc3806b6_0    conda-forge
pip                       23.2.1             pyhd8ed1ab_0    conda-forge
pixman                    0.40.0               h36c2ea0_0    conda-forge
pluggy                    1.3.0                    pypi_0    pypi
proto-plus                1.22.3             pyhd8ed1ab_0    conda-forge
protobuf                  4.23.3          py311hbec7ed6_0    conda-forge
pthread-stubs             0.4               h36c2ea0_1001    conda-forge
pyarrow                   11.0.0          py311hdf9aeb4_36_cpu    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pydot                     1.4.2           py311h38be061_3    conda-forge
pykerberos                1.2.4           py311h0820609_4    conda-forge
pymongo                   4.5.0           py311hb755f60_0    conda-forge
pyparsing                 3.1.1              pyhd8ed1ab_0    conda-forge
pysocks                   1.7.1              pyha2e5f31_6    conda-forge
pytest                    7.4.1                    pypi_0    pypi
python                    3.11.5          hab00c5b_0_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python-hdfs               2.7.0              pyhd8ed1ab_0    conda-forge
python-tzdata             2023.3             pyhd8ed1ab_0    conda-forge
python_abi                3.11                    3_cp311    conda-forge
pytz                      2023.3.post1       pyhd8ed1ab_0    conda-forge
rdma-core                 28.9                 h59595ed_1    conda-forge
re2                       2023.03.02           h8c504da_0    conda-forge
readline                  8.2                  h8228510_1    conda-forge
regex                     2023.8.8        py311h459d7ec_0    conda-forge
requests                  2.31.0             pyhd8ed1ab_0    conda-forge
requests-kerberos         0.12.0          py311h38be061_4    conda-forge
s2n                       1.3.49               h06160fa_0    conda-forge
setuptools                68.1.2             pyhd8ed1ab_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
snappy                    1.1.10               h9fff704_0    conda-forge
sniffio                   1.3.0              pyhd8ed1ab_0    conda-forge
tk                        8.6.12               h27826a3_0    conda-forge
typing-extensions         4.7.1                hd8ed1ab_0    conda-forge
typing_extensions         4.7.1              pyha770c72_0    conda-forge
tzdata                    2023c                h71feb2d_0    conda-forge
ucx                       1.14.1               h64cca9d_3    conda-forge
urllib3                   2.0.4              pyhd8ed1ab_0    conda-forge
wheel                     0.41.2             pyhd8ed1ab_0    conda-forge
xorg-kbproto              1.0.7             h7f98852_1002    conda-forge
xorg-libice               1.1.1                hd590300_0    conda-forge
xorg-libsm                1.2.4                h7391055_0    conda-forge
xorg-libx11               1.8.6                h8ee46fc_0    conda-forge
xorg-libxau               1.0.11               hd590300_0    conda-forge
xorg-libxdmcp             1.1.3                h7f98852_0    conda-forge
xorg-libxext              1.3.4                h0b41bf4_2    conda-forge
xorg-libxrender           0.9.11               hd590300_0    conda-forge
xorg-renderproto          0.11.1            h7f98852_1002    conda-forge
xorg-xextproto            7.3.0             h0b41bf4_1003    conda-forge
xorg-xproto               7.0.31            h7f98852_1007    conda-forge
xz                        5.2.6                h166bdaf_0    conda-forge
zlib                      1.2.13               hd590300_5    conda-forge
zstandard                 0.19.0          py311hd4cff14_0    conda-forge
zstd                      1.5.5                hfc55251_0    conda-forge

Environment info

Copied from https://github.com/cisaacstern/beam2.50.0-assert-that-bug/actions/runs/6103506815/job/16564018052?pr=1#step:6:12

     active environment : test
    active env location : /usr/share/miniconda3/envs/test
            shell level : 2
       user config file : /home/runner/.condarc
 populated config files : /usr/share/miniconda3/.condarc
                          /home/runner/.condarc
          conda version : 23.3.1
    conda-build version : not installed
         python version : 3.10.12.final.0
       virtual packages : __archspec=1=x86_64
                          __glibc=2.35=0
                          __linux=5.15.0=0
                          __unix=0=0
       base environment : /usr/share/miniconda3  (writable)
      conda av data dir : /usr/share/miniconda3/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /home/runner/conda_pkgs_dir
       envs directories : /usr/share/miniconda3/envs
                          /home/runner/.conda/envs
               platform : linux-64
             user-agent : conda/23.3.1 requests/2.31.0 CPython/3.10.12 Linux/5.15.0-1041-azure ubuntu/22.04.3 glibc/2.35
                UID:GID : 1001:999
             netrc file : None
           offline mode : False
@xylar
Copy link
Contributor

xylar commented Sep 7, 2023

I suspect that the issues is that apache-beam isn't compatible with cython >=3.0. There is an issue:
apache/beam#27526
which I had not previously noticed. I did not see any upper bound on cython in the setup.py or elsewhere in the python SDK.

I will make a new build of 2.50.0 with cython <3.0 and I will add your test above to the testing phase of our build to make sure it works.

xylar added a commit to xylar/apache-beam-feedstock that referenced this issue Sep 7, 2023
This should chatch the issue in conda-forge#67 if it hasn't been solved yet.
@xylar xylar mentioned this issue Sep 7, 2023
4 tasks
@xylar xylar closed this as completed in #68 Sep 7, 2023
@cisaacstern
Copy link
Author

Thanks for the lightening-fast triage, @xylar!

Confirming this fixed failing CI on the MRE: cisaacstern/beam2.50.0-assert-that-bug#1 (comment) 🎉

I wouldn't have guessed the Cython issue as the cause, and also thanks to #67 I now know how to add pytest checks to a Conda Forge feedstock. 😃

@xylar
Copy link
Contributor

xylar commented Sep 7, 2023

No problem! Glad to have this fixed before it caused too much trouble.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants