44import tarfile
55import traceback
66from abc import ABC , abstractmethod
7- from typing import Dict
7+ from typing import Dict , Optional
88
99import fsspec
1010import nbconvert
1414from jupyter_scheduler .models import DescribeJob , JobFeature , Status
1515from jupyter_scheduler .orm import Job , create_session
1616from jupyter_scheduler .parameterize import add_parameters
17- from jupyter_scheduler .utils import get_utc_timestamp
17+ from jupyter_scheduler .utils import copy_file , get_utc_timestamp
1818
1919
2020class ExecutionManager (ABC ):
@@ -29,11 +29,21 @@ class ExecutionManager(ABC):
2929 _model = None
3030 _db_session = None
3131
32- def __init__ (self , job_id : str , root_dir : str , db_url : str , staging_paths : Dict [str , str ]):
32+ def __init__ (
33+ self ,
34+ job_id : str ,
35+ root_dir : str ,
36+ db_url : str ,
37+ staging_paths : Dict [str , str ],
38+ input_uri : Optional [str ],
39+ package_input_folder : Optional [bool ],
40+ ):
3341 self .job_id = job_id
3442 self .staging_paths = staging_paths
3543 self .root_dir = root_dir
3644 self .db_url = db_url
45+ self .input_uri = input_uri
46+ self .package_input_folder = package_input_folder
3747
3848 @property
3949 def model (self ):
@@ -98,6 +108,17 @@ def before_start(self):
98108 )
99109 session .commit ()
100110
111+ def copy_input (self , input_uri : str , copy_to_path : str ):
112+ if self .package_input_folder :
113+ self .copy_input_folder (input_uri , copy_to_path )
114+ else :
115+ self .copy_input_file (input_uri , copy_to_path )
116+
117+ def copy_input_file (self , input_uri : str , copy_to_path : str ):
118+ """Copies the input file to the staging directory in a new process."""
119+ input_filepath = os .path .join (self .root_dir , input_uri )
120+ copy_file (input_filepath = input_filepath , copy_to_path = copy_to_path )
121+
101122 def on_failure (self , e : Exception ):
102123 """Called after failure of execute"""
103124 job = self .model
0 commit comments