fix governance reqs; allow for sandboxed jupyter notebooks for testing
This commit is contained in:
@@ -2,6 +2,10 @@ import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import {
|
||||
CohortBuildFile,
|
||||
Experiment,
|
||||
ExperimentDetail,
|
||||
ExperimentRequest,
|
||||
ModelLineage,
|
||||
ModelVersion,
|
||||
PromotionCheck,
|
||||
@@ -12,7 +16,7 @@ import {
|
||||
OcrRunSummary,
|
||||
} from './governance.types';
|
||||
|
||||
/** `/governance/*`: model versions, artifacts, and the OCR review queue. */
|
||||
/** `/governance/*`: model versions and their files, notebooks run on a cohort build, and the OCR review queue. */
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class GovernanceApi {
|
||||
private readonly http = inject(HttpClient);
|
||||
@@ -44,13 +48,44 @@ export class GovernanceApi {
|
||||
return this.http.patch<ModelVersion>(`/governance/model-versions/${domain}/${scenario}/${version}/reports`, reports);
|
||||
}
|
||||
|
||||
/** Logs the file to the version's MLflow run. Browsing/downloading a
|
||||
* logged artifact goes through the MLflow tracking server directly. */
|
||||
uploadArtifact(domain: string, scenario: string, version: string, kind: string, file: File): Observable<ModelVersion> {
|
||||
/** Where a file the version's run stored downloads from; a folder comes as a zip. */
|
||||
artifactUrl(domain: string, scenario: string, version: string, path: string): string {
|
||||
return `/governance/model-versions/${domain}/${scenario}/${version}/artifacts/${encodePath(path)}`;
|
||||
}
|
||||
|
||||
/** The domain's cohort builds that have their file. */
|
||||
cohortFiles(domain: string): Observable<{ builds: CohortBuildFile[] }> {
|
||||
return this.http.get<{ builds: CohortBuildFile[] }>('/governance/cohort-files', { params: toParams({ domain }) });
|
||||
}
|
||||
|
||||
listExperiments(filters: { domain?: string; scenario?: string } = {}): Observable<{ experiments: Experiment[] }> {
|
||||
return this.http.get<{ experiments: Experiment[] }>('/governance/experiments', { params: toParams(filters) });
|
||||
}
|
||||
|
||||
/** Starts the notebook on the build in the background; answers with the run while it is still `en_curso`. */
|
||||
runExperiment(request: ExperimentRequest): Observable<ExperimentDetail> {
|
||||
const form = new FormData();
|
||||
form.append('file', file);
|
||||
form.append('kind', kind);
|
||||
return this.http.post<ModelVersion>(`/governance/model-versions/${domain}/${scenario}/${version}/artifacts`, form);
|
||||
form.append('file', request.file);
|
||||
form.append('domain', request.domain);
|
||||
form.append('scenario', request.scenario);
|
||||
form.append('url', request.build.url);
|
||||
form.append('source', request.build.source);
|
||||
form.append('build', String(request.build.build));
|
||||
if (request.version) form.append('version', request.version);
|
||||
return this.http.post<ExperimentDetail>('/governance/experiments', form);
|
||||
}
|
||||
|
||||
getExperiment(runId: string): Observable<ExperimentDetail> {
|
||||
return this.http.get<ExperimentDetail>(`/governance/experiments/${runId}`);
|
||||
}
|
||||
|
||||
/** The rendered page, served sandboxed; opened in its own tab. */
|
||||
experimentPageUrl(runId: string): string {
|
||||
return `/governance/experiments/${runId}/page`;
|
||||
}
|
||||
|
||||
experimentArtifactUrl(runId: string, path: string): string {
|
||||
return `/governance/experiments/${runId}/artifacts/${encodePath(path)}`;
|
||||
}
|
||||
|
||||
listOcrJobs(): Observable<{ jobs: OcrJob[] }> {
|
||||
@@ -80,6 +115,10 @@ export class GovernanceApi {
|
||||
}
|
||||
}
|
||||
|
||||
function encodePath(path: string): string {
|
||||
return path.split('/').map(encodeURIComponent).join('/');
|
||||
}
|
||||
|
||||
function toParams(filters: Record<string, string | number | boolean | undefined>): HttpParams {
|
||||
let params = new HttpParams();
|
||||
for (const [key, value] of Object.entries(filters)) {
|
||||
|
||||
Reference in New Issue
Block a user