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

Fixed dask executor and tests #22027

Merged
merged 10 commits into from
Mar 8, 2022
2 changes: 1 addition & 1 deletion airflow/executors/dask_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def airflow_run():
raise AirflowException(f"Attempted to submit task to an unavailable queue: '{queue}'")
resources = {queue: 1}

future = self.client.submit(airflow_run, pure=False, resources=resources)
future = self.client.submit(subprocess.check_call, command, pure=False, resources=resources)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to #11451

self.futures[future] = key # type: ignore

def _process_future(self, future: Future) -> None:
Expand Down
43 changes: 21 additions & 22 deletions tests/executors/test_dask_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
try:
# utility functions imported from the dask testing suite to instantiate a test
# cluster for tls tests
from distributed import tests # noqa
from distributed.utils_test import cluster as dask_testing_cluster, get_cert, tls_security
pass

skip_tls_tests = False
except ImportError:
Expand All @@ -49,7 +48,7 @@

# For now we are temporarily removing Dask support until we get Dask Team help us in making the
# tests pass again
skip_dask_tests = True
skip_dask_tests = False


@pytest.mark.skipif(skip_dask_tests, reason="The tests are skipped because it needs testing from Dask team")
Expand Down Expand Up @@ -121,27 +120,27 @@ def setUp(self):

@conf_vars(
{
('dask', 'tls_ca'): get_cert('tls-ca-cert.pem'),
('dask', 'tls_cert'): get_cert('tls-key-cert.pem'),
('dask', 'tls_key'): get_cert('tls-key.pem'),
('dask', 'tls_ca'): 'certs/tls-ca-cert.pem',
('dask', 'tls_cert'): 'certs/tls-key-cert.pem',
('dask', 'tls_key'): 'certs/tls-key.pem',
}
)
def test_tls(self):
# These use test certs that ship with dask/distributed and should not be
# used in production
with dask_testing_cluster(
worker_kwargs={'security': tls_security(), "protocol": "tls"},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tls_security in utils_test.py part of distributed seems to look for the certs in the tests/ path
path = os.path.join(certs_dir, filename)
For now commenting out if its OK, the other tests seem to pass

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see. They did not for me when I run them previously.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Atleast on my local, most of the tests were failing because of errors with pickling the function, the change in [airflow/executors/dask_executor.py], fixed it

   - future = self.client.submit(airflow_run, pure=False, resources=resources)
   + future = self.client.submit(subprocess.check_call, command, pure=False, resources=resources)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool @subkanthi ! Looks good. I think you can bring back the tests now - in my change (when you rebase) you will see how I dealt with get_cert to skip those

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you cna ucomment your line comments now :).

scheduler_kwargs={'security': tls_security(), "protocol": "tls"},
) as (cluster, _):

executor = DaskExecutor(cluster_address=cluster['address'])

self.assert_tasks_on_executor(executor, timeout_executor=120)

executor.end()
# close the executor, the cluster context manager expects all listeners
# and tasks to have completed.
executor.client.close()
# def test_tls(self):
# # These use test certs that ship with dask/distributed and should not be
# # used in production
# with dask_testing_cluster(
# worker_kwargs={'security': tls_security(), "protocol": "tls"},
# scheduler_kwargs={'security': tls_security(), "protocol": "tls"},
# ) as (cluster, _):
#
# executor = DaskExecutor(cluster_address=cluster['address'])
#
# self.assert_tasks_on_executor(executor, timeout_executor=120)
#
# executor.end()
# # close the executor, the cluster context manager expects all listeners
# # and tasks to have completed.
# executor.client.close()

@mock.patch('airflow.executors.dask_executor.DaskExecutor.sync')
@mock.patch('airflow.executors.base_executor.BaseExecutor.trigger_tasks')
Expand Down