@@ -17,13 +17,13 @@ def __init__(
17
17
github_workflow_id : int ,
18
18
sftp_host : str ,
19
19
sftp_user : str ,
20
- sftp_private_key : str ,
20
+ sftp_private_key_path : str ,
21
21
metrics_directory_name : str = "metrics" ,
22
22
):
23
23
self .github_workflow_id = github_workflow_id
24
24
self .sftp_host = sftp_host
25
25
self .sftp_user = sftp_user
26
- self .sftp_private_key = sftp_private_key
26
+ self .sftp_private_key_path = sftp_private_key_path
27
27
self .metrics_dir = Path (metrics_directory_name )
28
28
29
29
def run (self ):
@@ -45,13 +45,10 @@ def send_file(self, file_path: Path):
45
45
Args:
46
46
file_path: Path to the file to send.
47
47
"""
48
- with tempfile .NamedTemporaryFile () as private_key_file :
49
- private_key_file .write (bytes (self .sftp_private_key , "utf-8" ))
50
- private_key_file .flush ()
51
- with pysftp .Connection (
52
- host = self .sftp_host , username = self .sftp_user , private_key = private_key_file .name
53
- ) as sftp :
54
- sftp .put (str (file_path ))
48
+ with pysftp .Connection (
49
+ host = self .sftp_host , username = self .sftp_user , private_key = self .sftp_private_key_path
50
+ ) as sftp :
51
+ sftp .put (str (file_path ))
55
52
56
53
@staticmethod
57
54
def write_file (pydantic_objects : List [OpTest ], file_path : Path ):
@@ -168,15 +165,15 @@ def collect_metrics(self, files: Dict[str, List[Path]]) -> List[OpTest]:
168
165
parser .add_argument ("--github_workflow_id" , type = int , help = "Github workflow id associated with the run." )
169
166
parser .add_argument ("--sftp_host" , type = str , help = "Sftp host." )
170
167
parser .add_argument ("--sftp_user" , type = str , help = "Sftp user." )
171
- parser .add_argument ("--sftp_private_key " , type = str , help = "Path to private key." )
168
+ parser .add_argument ("--sftp_private_key_path " , type = str , help = "Path to private key." )
172
169
173
170
args = parser .parse_args ()
174
171
175
172
sender = SendToDataTeam (
176
173
github_workflow_id = args .github_workflow_id ,
177
174
sftp_host = args .sftp_host ,
178
175
sftp_user = args .sftp_user ,
179
- sftp_private_key = args .sftp_private_key ,
176
+ sftp_private_key_path = args .sftp_private_key_path ,
180
177
)
181
178
182
179
sender .run ()
0 commit comments