데이터 통합사용 가능한 커넥터디렉토리

본 번역은 검증되지 않았습니다. AIP를 통해 영문원문으로부터 번역되었습니다.

디렉토리

디렉토리 커넥터는 역사적 출처로 문서화된 중단된 커넥터입니다. 이는 레거시 agent worker에서만 작동하며 Foundry worker에 해당하는 버전은 없습니다.

가능한 경우 SFTP, SMB, 또는 FTP와 같은 대체 파일 공유 커넥터를 사용하는 것을 권장합니다. 파일이 호스트 자체에서만 접근 가능하다면, 디렉토리 소스 대신 REST API 소스를 사용하는 외부 변환을 사용하는 것을 권장합니다.

디렉토리 커넥터는 Data Connection 에이전트가 실행 중인 호스트에 직접 위치한 파일을 가져올 수 있도록 합니다. 이 커넥터는 에이전트 머신에 로컬로 생성되거나 저장된 파일을 Foundry로 동기화해야 하는 시나리오에 유용합니다.

지원 기능

기능상태
탐색🟡 중단됨
배치 동기화🟡 중단됨
증분🟡 중단됨

데이터 모델

커넥터는 Foundry 데이터셋으로 모든 유형의 파일을 전송할 수 있습니다. 파일 형식은 유지되며, 전송 중 또는 이후에 스키마가 적용되지 않습니다. 필요한 경우 결과물 데이터셋에 스키마를 적용하거나 다운스트림 변환 작성을 통해 데이터를 액세스하세요.

설정

  1. Data Connection 애플리케이션을 열고 화면 오른쪽 상단에서 + New Source를 선택하기.
  2. 사용 가능한 커넥터 유형에서 Directory를 선택하기.
  3. 소스는 agent worker에서 실행되도록 구성됩니다.
  4. 추가 구성 프롬프트를 따라 커넥터 설정을 계속 진행하세요.

Foundry에서 커넥터 설정에 대해 더 확인 해주세요.

구성 옵션

옵션필수 여부설명
Root directory예이 연결을 통해 요청되는 모든 작업의 시작 디렉토리로 사용될 에이전트 호스트의 디렉토리입니다.

디렉토리에서 데이터 동기화

디렉토리 커넥터는 파일 기반 동기화 인터페이스를 사용합니다.

외부 변환을 사용하여 에이전트 호스트에서 파일 가져오기

더 많은 유연성과 제어를 위해 외부 변환을 사용하여 에이전트 호스트에서 파일을 가져올 수 있습니다. 이 접근 방식은 원격 에이전트 호스트의 파일에 액세스하면서도 Foundry worker에서 동기화 로직을 실행할 수 있도록 합니다.

사전 요구 사항

  1. REST API 소스 생성: Data Connection 애플리케이션으로 이동하여 새 REST API 소스를 생성하기.
  2. 연결 세부 정보 구성:
    • 도메인을 에이전트 호스트 주소로 설정하기 (또는 아래와 같이 프라이빗 IP 주소인 경우 플레이스홀더 도메인 이름 사용).
    • 포트를 22 (SSH)로 설정하기.
    • SSH 사용자 이름 및 비밀번호를 호스트에 SSH로 접속할 수 있는 사용자로 비밀로 추가하기.
  3. 에이전트 프록시 이그레스 정책 추가: 에이전트 호스트 주소 (또는 아래와 같이 프라이빗 IP 주소인 경우 플레이스홀더 도메인 이름 사용)에 대해 에이전트 자체로 지원되는 에이전트 프록시 이그레스 정책을 생성하기. 이를 통해 Foundry worker가 에이전트를 통해 에이전트 호스트에 트래픽을 라우팅할 수 있습니다.

에이전트 호스트 주소가 프라이빗 IP 주소인 경우 (예: 10.x.x.x, 172.16.x.x, 또는 192.168.x.x), 에이전트에서 프라이빗 IP를 플레이스홀더 도메인 이름으로 매핑하는 호스트 오버라이드 구성을 설정해야 합니다. REST 소스 및 이그레스 정책에서 도메인을 구성할 때 프라이빗 IP 주소 대신 이 플레이스홀더 도메인을 사용하세요.

  1. 소스를 Code Repositories에 가져오기: 외부 변환 설정 가이드를 따라 소스를 Python 변환 저장소로 가져오기.

Python 변환 저장소에 paramiko 라이브러리가 설치되어 있는지 확인하세요. Code Repositories의 왼쪽 패널에 있는 Libraries 탭을 통해 추가할 수 있습니다.

예제: SSH를 통해 에이전트 호스트에서 파일 읽기

다음 예제는 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 50 from 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()

예제: SSH를 통해 에이전트 호스트에서 파일 삭제

디렉토리 소스에서 가져온 후 파일을 확실히 삭제해야 하는 경우 완료 전략에 의존하는 대신 외부 변환을 사용할 수 있습니다. 완료 전략은 최선의 노력으로 삭제를 제공합니다.

아래 예제는 처리된 후 에이전트 호스트에서 파일을 삭제하는 방법을 보여줍니다. 이 접근 방식을 사용하려면:

  1. 디렉토리 소스에서 파일을 가져오고 성공적으로 가져온 파일 경로 목록을 데이터셋으로 출력하는 업스트림 동기화를 생성하기.
  2. 동기화 완료 후 이 삭제 변환을 실행하도록 예약하고, 입력으로 가져온 파일 경로 데이터셋을 사용하기.
  3. 출력 데이터셋은 각 파일의 삭제 상태를 포함하며, 성공적으로 삭제된 파일을 감사할 수 있습니다.
복구 불가능한 파일 삭제

이 작업은 에이전트 호스트 파일 시스템에서 파일을 영구적으로 삭제합니다. 실행 후 삭제된 파일은 복구할 수 없습니다. 이 변환을 실행하기 전에 파일이 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 51 from 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)