Sessions Python 플러그 인 마이그레이션 가이드 - 2025년 5월

SessionsPythonPlugin Azure Code Interpreter 동적 세션 API의 최신 버전(2024-10-02-preview)을 사용하도록 업데이트되었습니다. 새 API는 플러그인의 공용 API 표면에 반영되는 비호환 변경 사항을 도입했습니다.

이 마이그레이션 가이드는 기존 코드를 플러그 인의 최신 버전으로 마이그레이션하는 데 도움이 됩니다.

플러그 인 초기화

플러그인 생성자 서명이 변경되어 CancellationToken 함수에 authTokenProvider을 인수로 받을 수 있게 되었습니다. 이 변경을 통해 필요한 경우 토큰 생성 프로세스를 취소할 수 있습니다.

// Before
static async Task<string> GetAuthTokenAsync()
{
    return tokenProvider.GetToken();
}

// After
static async Task<string> GetAuthTokenAsync(CancellationToken ct)
{
    return tokenProvider.GetToken(ct);
}

var plugin = new SessionsPythonPlugin(settings, httpClientFactory, GetAuthTokenAsync);

UploadFileAsync 메서드

UploadFileAsync 메서드 시그니처가 매개 변수의 용도를 더 잘 나타내도록 변경되었습니다.

// Before
string remoteFilePath = "your_file.txt";
string? localFilePath = "C:\documents\your_file.txt";

await plugin.UploadFileAsync(remoteFilePath: remoteFilePath, localFilePath: localFilePath);

// After
string remoteFileName = "your_file.txt";
string localFilePath = "C:\documents\your_file.txt";

await plugin.UploadFileAsync(remoteFileName: remoteFileName, localFilePath: localFilePath);

DownloadFileAsync 메서드

마찬가지로 메서드 DownloadFileAsync 시그니처가 매개 변수의 용도를 더 잘 나타내도록 변경되었습니다.

// Before
string remoteFilePath = "your_file.txt";
await plugin.DownloadFileAsync(remoteFilePath: remoteFilePath);

// After
string remoteFileName = "your_file.txt";
await plugin.DownloadFileAsync(remoteFileName: remoteFileName);

ExecuteCodeAsync 메서드

ExecuteCodeAsync 메서드 시그니처가 변경되어 실행 결과를 사용할 수 있는 구조화된 방법을 제공합니다.

// Before
string result = await plugin.ExecuteCodeAsync(code: "print('Hello, world!')");

// After
SessionsPythonCodeExecutionResult result = await plugin.ExecuteCodeAsync(code: "print('Hello, world!')");
string status = result.Status;
string? executionResult = result.Result?.ExecutionResult;
string? stdout = result.Result?.StdOut;
string? stderr = result.Result?.StdErr;

SessionsRemoteFileMetadata 클래스

SessionsRemoteFileMetadata 및 메서드에서 UploadFileAsyncListFilesAsync 사용하는 모델 클래스가 원격 파일 및 디렉터리 메타데이터를 더 잘 나타내도록 업데이트되었습니다.

// Before
SessionsRemoteFileMetadata file = await plugin.UploadFileAsync(...);
string fileName = file.Filename;
long fileSize = file.Size;
DateTime? lastModified = file.LastModifiedTime;

// After
SessionsRemoteFileMetadata file = await plugin.UploadFileAsync(...);
string name = file.Name;
long? size = file.SizeInBytes;
DateTime lastModified = file.LastModifiedAt;