1
1
import os
2
2
import random
3
3
import tarfile
4
- from multiprocessing import Process
5
- from typing import Dict , List , Optional , Type
4
+ from typing import Awaitable , Dict , List , Optional , Type
6
5
7
6
import fsspec
7
+ from dask .distributed import Client as DaskClient
8
8
from jupyter_server .utils import ensure_async
9
9
10
10
from jupyter_scheduler .exceptions import SchedulerError
14
14
class JobFilesManager :
15
15
scheduler = None
16
16
17
- def __init__ (self , scheduler : Type [BaseScheduler ]):
17
+ def __init__ (
18
+ self ,
19
+ scheduler : Type [BaseScheduler ],
20
+ ):
18
21
self .scheduler = scheduler
19
22
20
23
async def copy_from_staging (self , job_id : str , redownload : Optional [bool ] = False ):
@@ -23,8 +26,9 @@ async def copy_from_staging(self, job_id: str, redownload: Optional[bool] = Fals
23
26
output_filenames = self .scheduler .get_job_filenames (job )
24
27
output_dir = self .scheduler .get_local_output_path (model = job , root_dir_relative = True )
25
28
26
- p = Process (
27
- target = Downloader (
29
+ dask_client : DaskClient = await self .scheduler .dask_client_future
30
+ dask_client .submit (
31
+ Downloader (
28
32
output_formats = job .output_formats ,
29
33
output_filenames = output_filenames ,
30
34
staging_paths = staging_paths ,
@@ -33,7 +37,6 @@ async def copy_from_staging(self, job_id: str, redownload: Optional[bool] = Fals
33
37
include_staging_files = job .package_input_folder ,
34
38
).download
35
39
)
36
- p .start ()
37
40
38
41
39
42
class Downloader :
0 commit comments