2
2
import os
3
3
import random
4
4
import shutil
5
- from typing import Awaitable , Dict , List , Optional , Type , Union
5
+ from typing import Dict , List , Optional , Type , Union
6
6
7
7
import fsspec
8
8
import psutil
@@ -421,12 +421,11 @@ def __init__(
421
421
if self .task_runner_class :
422
422
self .task_runner = self .task_runner_class (scheduler = self , config = config )
423
423
424
- loop = asyncio .get_event_loop ()
425
- self .dask_client_future : Awaitable [DaskClient ] = loop .create_task (self ._get_dask_client ())
424
+ self .dask_client : DaskClient = self ._get_dask_client ()
426
425
427
- async def _get_dask_client (self ):
426
+ def _get_dask_client (self ):
428
427
"""Creates and configures a Dask client."""
429
- return DaskClient (processes = False , asynchronous = True )
428
+ return DaskClient ()
430
429
431
430
@property
432
431
def db_session (self ):
@@ -451,7 +450,7 @@ def copy_input_folder(self, input_uri: str, nb_copy_to_path: str) -> List[str]:
451
450
destination_dir = staging_dir ,
452
451
)
453
452
454
- async def create_job (self , model : CreateJob ) -> str :
453
+ def create_job (self , model : CreateJob ) -> str :
455
454
if not model .job_definition_id and not self .file_exists (model .input_uri ):
456
455
raise InputUriError (model .input_uri )
457
456
@@ -492,8 +491,7 @@ async def create_job(self, model: CreateJob) -> str:
492
491
else :
493
492
self .copy_input_file (model .input_uri , staging_paths ["input" ])
494
493
495
- dask_client : DaskClient = await self .dask_client_future
496
- future = dask_client .submit (
494
+ future = self .dask_client .submit (
497
495
self .execution_manager_class (
498
496
job_id = job .job_id ,
499
497
staging_paths = staging_paths ,
@@ -755,16 +753,14 @@ def list_job_definitions(self, query: ListJobDefinitionsQuery) -> ListJobDefinit
755
753
756
754
return list_response
757
755
758
- async def create_job_from_definition (
759
- self , job_definition_id : str , model : CreateJobFromDefinition
760
- ):
756
+ def create_job_from_definition (self , job_definition_id : str , model : CreateJobFromDefinition ):
761
757
job_id = None
762
758
definition = self .get_job_definition (job_definition_id )
763
759
if definition :
764
760
input_uri = self .get_staging_paths (definition )["input" ]
765
761
attributes = definition .dict (exclude = {"schedule" , "timezone" }, exclude_none = True )
766
762
attributes = {** attributes , ** model .dict (exclude_none = True ), "input_uri" : input_uri }
767
- job_id = await self .create_job (CreateJob (** attributes ))
763
+ job_id = self .create_job (CreateJob (** attributes ))
768
764
769
765
return job_id
770
766
@@ -789,9 +785,8 @@ async def stop_extension(self):
789
785
"""
790
786
Cleanup code to run when the server is stopping.
791
787
"""
792
- if self .dask_client_future :
793
- dask_client : DaskClient = await self .dask_client_future
794
- await dask_client .close ()
788
+ if self .dask_client :
789
+ self .dask_client .close ()
795
790
796
791
797
792
class ArchivingScheduler (Scheduler ):
0 commit comments