Skip to content

Commit

Permalink
Merge pull request #425 from alercebroker/feat/classifiers-priority
Browse files Browse the repository at this point in the history
Feature: Classifier model priority
  • Loading branch information
AlxEnashi authored Aug 27, 2024
2 parents 2a0d9cd + 06a708a commit a293480
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 18 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,7 @@ sw.*
# Deploy files
deploy.sh
.awspublish-*

# Nix
flake.lock
flake.nix
13 changes: 9 additions & 4 deletions components/cardClassifiers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

<script>
import { Vue, Component, Prop } from 'nuxt-property-decorator'
import { filterSortClassifiers } from '../utils/classifier_sort'
@Component
export default class CardClassifiers extends Vue {
Expand Down Expand Up @@ -99,15 +100,19 @@ export default class CardClassifiers extends Vue {
get classifiers_() {
const grouped = this.groupBy(this.classifiers, 'classifier_name')
const keys = Object.keys(grouped)
const res = []
keys.forEach((k, i) => {
let res = []
keys.forEach((k) => {
const latestVersion = this.getLatestVersion(grouped[k])
res.push({
name: this.formatClassifierName(k),
name: k,
probs: this.formatProbs(grouped[k], latestVersion),
index: i,
})
})
res = filterSortClassifiers(res)
res.map((r, idx) => {
r.name = this.formatClassifierName(r.name)
r.index = idx
})
return res
}
Expand Down
9 changes: 7 additions & 2 deletions components/cardLightCurve.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,15 @@ export default class CardLightCurve extends Vue {
}
_loadHtmx(objectId) {
const url = `${this.$config.ztfApiv2Url}/lightcurve/htmx/lightcurve?oid=${objectId}`
const url = new URL(
'/v2/lightcurve/htmx/lightcurve',
this.$config.alerceApiBaseUrl
)
url.searchParams.append('oid', objectId)
const myDiv = document.getElementById('lightcurve-app')
if (myDiv) {
myDiv.innerHTML = `<div hx-get=${url} hx-trigger="updateLightcurve once from:body" hx-swap="outerHTML"></div>`
myDiv.innerHTML = `<div hx-get=${url.toString()} hx-trigger="updateLightcurve once from:body" hx-swap="outerHTML"></div>`
htmx.process(myDiv)
document.body.dispatchEvent(new Event('updateLightcurve'))
}
Expand Down
10 changes: 3 additions & 7 deletions nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,12 @@ export default {
*/
publicRuntimeConfig: {
avroApiBaseUrl:
process.env.AVRO_API_BASE_URL || 'https://dev.avro.alerce.online',
process.env.AVRO_API_BASE_URL || 'https://avro.alerce.online',
catshtmApiBaseUrl:
process.env.CATSHTM_API_BASE_URL || 'https://catshtm.alerce.online',
tnsApiBaseUrl: process.env.TNS_API_BASE_URL || 'https://tns.alerce.online',
drApiBaseUrl:
process.env.ZTF_DR_API_BASE_URL || 'https://api.alerce.online/ztf/dr/v1',
ztfApiBaseUrl:
process.env.ZTF_API_BASE_URL ||
'https://dev-api.alerce.online/alerts/v1/',
ztfApiv2Url: process.env.ZTF_V2_API_URL || 'https://api.alerce.online/v2',
alerceApiBaseUrl:
process.env.ALERCE_API_BASE_URL || 'https://api.alerce.online/',
usersApiBaseUrl:
process.env.USERS_API_BASE_URL || 'https://dev.users.alerce.online/users',
googleRedirectUri:
Expand Down
2 changes: 1 addition & 1 deletion plugins/dataReleaseApi.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default function ({ $axios, $config }, inject) {
const dataReleaseApi = $axios.create({
baseURL: $config.drApiBaseUrl,
baseURL: new URL('/ztf/dr/v1', $config.alerceApiBaseUrl).toString(),
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Expand Down
8 changes: 4 additions & 4 deletions plugins/ztfApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ function filterFunc(prefix, value) {

export default function ({ $axios, $config }, inject) {
const ztfApi = $axios.create({
baseURL: $config.ztfApiBaseUrl,
baseURL: new URL('/alerts/v1', $config.alerceApiBaseUrl).toString(),
})
const ztfApiv2 = $axios.create({
baseURL: $config.ztfApiv2Url,
const lightcurveApi = $axios.create({
baseURL: new URL('/v2/lightcurve', $config.alerceApiBaseUrl).toString(),
})

ztfApi.search = (searchParameters, request) => {
Expand Down Expand Up @@ -83,7 +83,7 @@ export default function ({ $axios, $config }, inject) {
'AUTH-TOKEN': token,
}
}
return ztfApiv2.get(`/lightcurve/lightcurve/${objectId}`, config)
return lightcurveApi.get(`/lightcurve/${objectId}`, config)
}

ztfApi.getStats = (oid, request = null) => {
Expand Down
2 changes: 2 additions & 0 deletions store/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
VuexMutation,
VuexAction,
} from 'nuxt-property-decorator'
import { filterSortClassifiers } from '../utils/classifier_sort'
import { objectsStore, paginationStore } from '~/store'
const defaultState = {
oid: [],
Expand Down Expand Up @@ -201,6 +202,7 @@ export default class Filters extends VuexModule {
x.name = x.classifier_name
return x
})
this.classifiers = filterSortClassifiers(this.classifiers)
}

@VuexMutation
Expand Down
12 changes: 12 additions & 0 deletions utils/classifier_sort.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const priorities = {
lc_classifier: 0,
lc_classifier_top: 1,
stamp_classifier: 2,
'LC_classifier_ATAT_forced_phot(beta)': 3,
'LC_classifier_BHRF_forced_phot(beta)': 4,
}
export function filterSortClassifiers(classifiers) {
return classifiers
.filter((classifier) => classifier.name in priorities)
.sort((a, b) => priorities[a.name] - priorities[b.name])
}

0 comments on commit a293480

Please sign in to comment.