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 ):
@@ -97,6 +107,18 @@ def before_start(self):
97107 {"start_time" : get_utc_timestamp (), "status" : Status .IN_PROGRESS }
98108 )
99109 session .commit ()
110+ self .copy_input (self .input_uri , self .staging_paths ["input" ])
111+
112+ def copy_input (self , input_uri : str , copy_to_path : str ):
113+ if self .package_input_folder :
114+ self .copy_input_folder (input_uri , copy_to_path )
115+ else :
116+ self .copy_input_file (input_uri , copy_to_path )
117+
118+ def copy_input_file (self , input_uri : str , copy_to_path : str ):
119+ """Copies the input file to the staging directory in a new process."""
120+ input_filepath = os .path .join (self .root_dir , input_uri )
121+ copy_file (input_filepath = input_filepath , copy_to_path = copy_to_path )
100122
101123 def on_failure (self , e : Exception ):
102124 """Called after failure of execute"""
0 commit comments