-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ML] Versioning all ML APIs #156949
[ML] Versioning all ML APIs #156949
Changes from all commits
1ca33c2
072757d
0dd0794
f01bd5d
c1fa1f9
c266ab7
4d92c0e
deb51ab
25a9f6f
b979575
0c0e003
0d767d0
94e77fc
47f2185
b57f000
e209129
c05264d
24c3818
1a14d02
412b5c5
03d60fe
7b1c693
a5bc2cc
8adac57
5ed56f3
df24ed4
87013eb
de5f053
ebb12df
8052aac
134c219
9671116
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,53 +7,32 @@ | |
|
||
import { Observable } from 'rxjs'; | ||
import { map } from 'rxjs/operators'; | ||
import { Job, JobId } from '../../../common/types/anomaly_detection_jobs'; | ||
import { basePath } from './ml_api_service'; | ||
import type { Job, JobId } from '../../../common/types/anomaly_detection_jobs'; | ||
import { HttpService } from './http_service'; | ||
import { type MlApiServices, mlApiServicesProvider } from './ml_api_service'; | ||
|
||
export class AnomalyDetectorService { | ||
private readonly apiBasePath = basePath() + '/anomaly_detectors'; | ||
private mlApiServices: MlApiServices; | ||
|
||
constructor(private httpService: HttpService) {} | ||
constructor(httpService: HttpService) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've updated this class to remove the API calls directly using I've also removed the |
||
this.mlApiServices = mlApiServicesProvider(httpService); | ||
} | ||
|
||
/** | ||
* Fetches a single job object | ||
* @param jobId | ||
*/ | ||
getJobById$(jobId: JobId): Observable<Job> { | ||
return this.httpService | ||
.http$<{ count: number; jobs: Job[] }>({ | ||
path: `${this.apiBasePath}/${jobId}`, | ||
}) | ||
.pipe(map((response) => response.jobs[0])); | ||
return this.getJobs$([jobId]).pipe(map((jobs) => jobs[0])); | ||
} | ||
|
||
/** | ||
* Fetches anomaly detection jobs by ids | ||
* @param jobIds | ||
*/ | ||
getJobs$(jobIds: JobId[]): Observable<Job[]> { | ||
return this.httpService | ||
.http$<{ count: number; jobs: Job[] }>({ | ||
path: `${this.apiBasePath}/${jobIds.join(',')}`, | ||
}) | ||
return this.mlApiServices | ||
.getJobs$({ jobId: jobIds.join(',') }) | ||
.pipe(map((response) => response.jobs)); | ||
} | ||
|
||
/** | ||
* Extract unique influencers from the job or collection of jobs | ||
* @param jobs | ||
*/ | ||
extractInfluencers(jobs: Job | Job[]): string[] { | ||
if (!Array.isArray(jobs)) { | ||
jobs = [jobs]; | ||
} | ||
const influencers = new Set<string>(); | ||
for (const job of jobs) { | ||
for (const influencer of job.analysis_config.influencers || []) { | ||
influencers.add(influencer); | ||
} | ||
} | ||
return Array.from(influencers); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved from
AnomalyDetectorService
as it doesn't need to live inside the class.