디렉토리 커넥터는 역사적 출처로 문서화된 중단된 커넥터입니다. 이는 레거시 agent worker에서만 작동하며 Foundry worker에 해당하는 버전은 없습니다.
가능한 경우 SFTP, SMB, 또는 FTP와 같은 대체 파일 공유 커넥터를 사용하는 것을 권장합니다. 파일이 호스트 자체에서만 접근 가능하다면, 디렉토리 소스 대신 REST API 소스를 사용하는 외부 변환을 사용하는 것을 권장합니다.
디렉토리 커넥터는 Data Connection 에이전트가 실행 중인 호스트에 직접 위치한 파일을 가져올 수 있도록 합니다. 이 커넥터는 에이전트 머신에 로컬로 생성되거나 저장된 파일을 Foundry로 동기화해야 하는 시나리오에 유용합니다.
| 기능 | 상태 |
|---|---|
| 탐색 | 🟡 중단됨 |
| 배치 동기화 | 🟡 중단됨 |
| 증분 | 🟡 중단됨 |
커넥터는 Foundry 데이터셋으로 모든 유형의 파일을 전송할 수 있습니다. 파일 형식은 유지되며, 전송 중 또는 이후에 스키마가 적용되지 않습니다. 필요한 경우 결과물 데이터셋에 스키마를 적용하거나 다운스트림 변환 작성을 통해 데이터를 액세스하세요.
Foundry에서 커넥터 설정에 대해 더 확인 해주세요.
| 옵션 | 필수 여부 | 설명 |
|---|---|---|
Root directory | 예 | 이 연결을 통해 요청되는 모든 작업의 시작 디렉토리로 사용될 에이전트 호스트의 디렉토리입니다. |
디렉토리 커넥터는 파일 기반 동기화 인터페이스를 사용합니다.
더 많은 유연성과 제어를 위해 외부 변환을 사용하여 에이전트 호스트에서 파일을 가져올 수 있습니다. 이 접근 방식은 원격 에이전트 호스트의 파일에 액세스하면서도 Foundry worker에서 동기화 로직을 실행할 수 있도록 합니다.
22 (SSH)로 설정하기.에이전트 호스트 주소가 프라이빗 IP 주소인 경우 (예: 10.x.x.x, 172.16.x.x, 또는 192.168.x.x), 에이전트에서 프라이빗 IP를 플레이스홀더 도메인 이름으로 매핑하는 호스트 오버라이드 구성을 설정해야 합니다. REST 소스 및 이그레스 정책에서 도메인을 구성할 때 프라이빗 IP 주소 대신 이 플레이스홀더 도메인을 사용하세요.
Python 변환 저장소에 paramiko 라이브러리가 설치되어 있는지 확인하세요. Code Repositories의 왼쪽 패널에 있는 Libraries 탭을 통해 추가할 수 있습니다.
다음 예제는 SSH를 통해 에이전트 호스트에 연결하고 Paramiko ↗ Python 라이브러리를 사용하여 Foundry 데이터셋으로 파일을 읽는 방법을 보여줍니다.
Copied!1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50from transforms.api import transform, Output, Input, LightweightOutput, LightweightInput, lightweight from transforms.external.systems import external_systems, Source, ResolvedSource import paramiko @lightweight @external_systems( agent_source=Source("<source_rid>") # Replace with your REST API source RID ) @transform( output_dataset=Output("<output_dataset_rid>"), # Replace with your output dataset RID files_to_read=Input("<input_dataset_rid>"), # Dataset containing file paths to read ) def compute( agent_source: ResolvedSource, output_dataset: LightweightOutput, files_to_read: LightweightInput, ): """ Read files from a remote agent host via SSH and write them to a Foundry dataset. """ # 1. SSH connection setup hostname = "<agent_hostname>" # Replace with your agent hostname username = "<ssh_username>" # Replace with your SSH username password = agent_source.get_secret("<password_secret_name>") # Replace with your secret name # 2. Establish SSH connection client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(hostname, username=username, password=password) # 3. Read file paths from input dataset remote_file_paths = files_to_read.pandas()["remote_file_path"].tolist() # 4. Open SFTP connection sftp = client.open_sftp() # 5. Read each file and write to output dataset for remote_path in remote_file_paths: with sftp.open(remote_path, "rb") as remote_file: file_binary_data = remote_file.read() # Extract filename from path and write to output filename = remote_path.split("/")[-1] with output_dataset.filesystem().open(filename, "wb") as f: f.write(file_binary_data) # 6. Close connections sftp.close() client.close()
디렉토리 소스에서 가져온 후 파일을 확실히 삭제해야 하는 경우 완료 전략에 의존하는 대신 외부 변환을 사용할 수 있습니다. 완료 전략은 최선의 노력으로 삭제를 제공합니다.
아래 예제는 처리된 후 에이전트 호스트에서 파일을 삭제하는 방법을 보여줍니다. 이 접근 방식을 사용하려면:
이 작업은 에이전트 호스트 파일 시스템에서 파일을 영구적으로 삭제합니다. 실행 후 삭제된 파일은 복구할 수 없습니다. 이 변환을 실행하기 전에 파일이 Foundry에 성공적으로 가져왔는지 확인하세요.
Copied!1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51from transforms.api import transform, Output, Input, LightweightOutput, LightweightInput, lightweight from transforms.external.systems import external_systems, Source, ResolvedSource import paramiko @lightweight @external_systems( agent_source=Source("<source_rid>") # Replace with your REST API source RID ) @transform( output_dataset=Output("<output_dataset_rid>"), # Replace with your output dataset RID files_to_delete=Input("<input_dataset_rid>"), # Dataset containing file paths to delete ) def compute( agent_source: ResolvedSource, output_dataset: LightweightOutput, files_to_delete: LightweightInput, ): """ Delete files from a remote agent host via SSH. Input dataset should contain a column 'remote_file_path' with absolute paths to delete. """ hostname = "<agent_hostname>" # Replace with your agent hostname username = "<ssh_username>" # Replace with your SSH username password = agent_source.get_secret("<password_secret_name>") # Replace with your secret name client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(hostname, username=username, password=password) remote_file_paths = files_to_delete.pandas()["remote_file_path"].tolist() sftp = client.open_sftp() deletion_results = [] for remote_path in remote_file_paths: try: sftp.remove(remote_path) deletion_results.append({"file": remote_path, "status": "deleted"}) except FileNotFoundError: deletion_results.append({"file": remote_path, "status": "not_found"}) except PermissionError: deletion_results.append({"file": remote_path, "status": "permission_denied"}) sftp.close() client.close() # Write deletion results to output dataset import pandas as pd results_df = pd.DataFrame(deletion_results) output_dataset.write_pandas(results_df)