@@ -490,6 +490,18 @@ def get_run_plan(
490490 if repo_dir is None and configuration .repos :
491491 repo_dir = configuration .repos [0 ].path
492492
493+ self ._validate_configuration_files (configuration , configuration_path )
494+ file_archives : list [FileArchiveMapping ] = []
495+ for file_mapping in configuration .files :
496+ with tempfile .TemporaryFile ("w+b" ) as fp :
497+ try :
498+ archive_hash = create_file_archive (file_mapping .local_path , fp )
499+ except OSError as e :
500+ raise ClientError (f"failed to archive '{ file_mapping .local_path } ': { e } " ) from e
501+ fp .seek (0 )
502+ archive = self ._api_client .files .upload_archive (hash = archive_hash , fp = fp )
503+ file_archives .append (FileArchiveMapping (id = archive .id , path = file_mapping .path ))
504+
493505 if ssh_identity_file :
494506 ssh_key_pub = Path (ssh_identity_file ).with_suffix (".pub" ).read_text ()
495507 else :
@@ -513,6 +525,7 @@ def get_run_plan(
513525 repo_data = repo .run_repo_data ,
514526 repo_code_hash = repo_code_hash ,
515527 repo_dir = repo_dir ,
528+ file_archives = file_archives ,
516529 # Server doesn't use this field since 0.19.27, but we still send it for compatibility
517530 # with older servers
518531 working_dir = configuration .working_dir ,
@@ -549,22 +562,6 @@ def apply_plan(
549562 # TODO handle multiple jobs
550563 ports_lock = _reserve_ports (run_plan .job_plans [0 ].job_spec )
551564
552- run_spec = run_plan .run_spec
553- configuration = run_spec .configuration
554-
555- self ._validate_configuration_files (configuration , run_spec .configuration_path )
556- for file_mapping in configuration .files :
557- with tempfile .TemporaryFile ("w+b" ) as fp :
558- try :
559- archive_hash = create_file_archive (file_mapping .local_path , fp )
560- except OSError as e :
561- raise ClientError (f"failed to archive '{ file_mapping .local_path } ': { e } " ) from e
562- fp .seek (0 )
563- archive = self ._api_client .files .upload_archive (hash = archive_hash , fp = fp )
564- run_spec .file_archives .append (
565- FileArchiveMapping (id = archive .id , path = file_mapping .path )
566- )
567-
568565 if repo is None :
569566 repo = VirtualRepo ()
570567 else :
0 commit comments