Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions multisurveys-apis/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ lightcurve = "scripts.run_api:run_lightcurve"
magstat = "scripts.run_api:run_magstat"
classifier = "scripts.run_api:run_classifier"
probability = "scripts.run_api:run_probability"
crossmatch = "scripts.run_api:run_crossmatch"
dbp = "db_plugins.cli.manage:cli"
initdb = "scripts.initdb:initdb"
create_q3c_idx = "scripts.initdb:create_q3c_idx_cmd"
Expand Down
7 changes: 7 additions & 0 deletions multisurveys-apis/scripts/run_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ def run_probability():
run_service(service_config)


def run_crossmatch():
config_dict = config_from_yaml()
service_config = config_dict["services"]["crossmatch_api"]
print(f"Running service: crossmatch_api with config: {service_config}")
run_service(service_config)


###
### A function to run all the services configured in the yaml file
###
Expand Down
1 change: 1 addition & 0 deletions multisurveys-apis/src/classifier_api/services/parsers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pprint
from ..models.classifiers import Classifiers


Expand Down
28 changes: 28 additions & 0 deletions multisurveys-apis/src/core/repository/dummy_data.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import random
import time


object_basic_information_dict = {
Expand Down Expand Up @@ -116,3 +118,29 @@
{'lc_classifier': 'Lc Classifier'},
{'LC_classifier_ATAT_forced_phot': 'Lc Classifier ATAT Forced Phot'},
]


def generate_array_dicts_data_table(n=20, seed=None):
rnd = random.Random(seed if seed is not None else time.time_ns())
base_oid = rnd.randint(10000, 99999)

rows = []
for i in range(n):
oid = f"{base_oid + i}"
n_det = rnd.randint(5, 45)
firstmjd = 57900.0 + rnd.uniform(0, 200)
lastmjd = firstmjd + rnd.uniform(10, 200)
meanra = round(rnd.uniform(0, 360), 5)
meandec = round(rnd.uniform(-90, 90), 5)
probability = round(rnd.uniform(0.5, 0.99), 2)

rows.append({
'oid': oid,
'n_det': n_det,
'firstmjd': round(firstmjd, 3),
'lastmjd': round(lastmjd, 3),
'meanra': meanra,
'meandec': meandec,
'Probability': probability
})
return rows
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ def get_all_classifiers(
)
result = session.execute(stmt)
result = result.all()

return result
6 changes: 3 additions & 3 deletions multisurveys-apis/src/crossmatch_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
allow_headers=["*"],
)

app.mount("/static", StaticFiles(directory="src/crossmatch_api/static"), name="static")
app.mount("/htmx-static", StaticFiles(directory="src/htmx"), name="htmx-static")

app.include_router(rest.router)
app.include_router(htmx.router)

app.mount("/static", StaticFiles(directory="src/crossmatch_api/static"), name="static")
app.mount("/htmx", StaticFiles(directory="src/core/htmx"), name="htmx")

1 change: 1 addition & 0 deletions multisurveys-apis/src/crossmatch_api/routes/htmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"API_URL", "http://localhost:8005"
)


@router.get("/htmx/crossmatch", response_class=HTMLResponse)
async def object_mag_app(
request: Request,
Expand Down
38 changes: 29 additions & 9 deletions multisurveys-apis/src/object_api/routes/htmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from ..services.jinja_tools import truncate_float
from core.exceptions import ObjectNotFound

from core.repository.dummy_data import object_basic_information_dict, tns_data_dict, tns_link_str
from core.repository.dummy_data import object_basic_information_dict, tns_data_dict, tns_link_str, generate_array_dicts_data_table


router = APIRouter()
Expand All @@ -37,7 +37,7 @@
templates.env.filters["truncate"] = truncate_float


@router.get("/htmx/object", response_class=HTMLResponse)
@router.get("/htmx/object_information", response_class=HTMLResponse)
async def object_info_app(request: Request, oid: str, survey_id: str):
try:
session = request.app.state.psql_session
Expand Down Expand Up @@ -72,7 +72,7 @@ async def object_info_app(request: Request, oid: str, survey_id: str):
)


@router.get("/tns/", response_class=HTMLResponse)
@router.get("/htmx/tns/", response_class=HTMLResponse)
async def tns_info(request: Request, ra: float, dec:float):
try:
# tns_data, tns_link = get_tns(ra, dec)
Expand All @@ -95,7 +95,7 @@ async def tns_info(request: Request, ra: float, dec:float):
)


@router.get("/form/", response_class=HTMLResponse)
@router.get("/htmx/search_objects/", response_class=HTMLResponse)
async def objects_form(request: Request):
try:
session = request.app.state.psql_session
Expand All @@ -110,7 +110,7 @@ async def objects_form(request: Request):
raise HTTPException(status_code=500, detail="An error occurred")


@router.get("/select", response_class=HTMLResponse)
@router.get("/htmx/classes_select", response_class=HTMLResponse)
async def select_classes_classifier(request: Request, classifier_classes: list[str] = Query(...)):
try:
classes = classifier_classes
Expand All @@ -124,7 +124,7 @@ async def select_classes_classifier(request: Request, classifier_classes: list[s
raise HTTPException(status_code=500, detail="An error occurred")


@router.get("/table", response_class=HTMLResponse)
@router.get("/htmx/list_objects", response_class=HTMLResponse)
def objects_table(
request: Request,
class_name: str | None = None,
Expand Down Expand Up @@ -187,7 +187,18 @@ def objects_table(
order_args=order,
)

object_list = get_objects_list(session_ms=session, search_params=search_params)
# object_list = get_objects_list(session_ms=session, search_params=search_params)


object_list = {
"next": page+1,
"has_next": True,
"prev": page - 1 ,
"has_prev": True,
"current_page": page,
"items": generate_array_dicts_data_table(),
}

else:
object_list = {
"next": False,
Expand Down Expand Up @@ -219,7 +230,7 @@ def objects_table(
raise HTTPException(status_code=500, detail="An error occurred")


@router.get("/sidebar", response_class=HTMLResponse)
@router.get("/htmx/side_objects", response_class=HTMLResponse)
def sidebar(
request: Request,
survey: str | None = None,
Expand Down Expand Up @@ -279,7 +290,16 @@ def sidebar(
order_args=order,
)

object_list = get_objects_list(session_ms=session, search_params=search_params)
# object_list = get_objects_list(session_ms=session, search_params=search_params)

object_list = {
"next": page+1,
"has_next": True,
"prev": page - 1 ,
"has_prev": True,
"current_page": page,
"items": generate_array_dicts_data_table(),
}

else:
object_list = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def format_classifier_name(name):


def sort_classifiers(classifiers):
sort_arr_classifiers = [None] * 6
sort_arr_classifiers = [None] * 7

priorities = {
"lc_classifier": 0,
Expand All @@ -19,6 +19,7 @@ def sort_classifiers(classifiers):
"LC_classifier_ATAT_forced_phot": 3,
"LC_classifier_BHRF_forced_phot": 4,
"lc_classifier_lsst": 5,
"rubin_stamp_1": 6
}

# insertar por prioridad
Expand Down
32 changes: 19 additions & 13 deletions multisurveys-apis/src/object_api/static/draw_elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,29 @@ export function draw_oids_tags(oids_arr){


export function draw_arrow_order_table(order_mode){
let svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
svg.id = 'selected_order_table'
svg.setAttribute("xmlns", "http://www.w3.org/2000/svg");
svg.setAttribute("height", "24px");
svg.setAttribute("viewBox", "0 -960 960 960");
svg.setAttribute("width", "24px");
svg.setAttribute("fill", "#FFFFFF");

let path = document.createElementNS("http://www.w3.org/2000/svg", "path");
// let svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
// svg.id = 'selected_order_table'
// svg.setAttribute("viewBox", "0 -960 960 960");
// svg.classList.add("tw-w-[18px]", "tw-h-[18px]", "tw-fill-black", "dark:tw-fill-white")


// let path = document.createElementNS("http://www.w3.org/2000/svg", "path");
let svg
if(order_mode == 'DESC'){
path.setAttribute("d", "M480-240 240-480l56-56 144 144v-368h80v368l144-144 56 56-240 240Z");
// path.setAttribute("d", "M480-240 240-480l56-56 144 144v-368h80v368l144-144 56 56-240 240Z");
svg = `<svg id='selected_order_table' class="tw-w-[18px] tw-h-[18px] tw-inline-block tw-fill-black dark:tw-fill-white" viewBox="0 -960 960 960">
<path d="M480-240 240-480l56-56 144 144v-368h80v368l144-144 56 56-240 240Z"/>
</svg>`
} else {
path.setAttribute("d", "M440-240v-368L296-464l-56-56 240-240 240 240-56 56-144-144v368h-80Z");
// path.setAttribute("d", "M440-240v-368L296-464l-56-56 240-240 240 240-56 56-144-144v368h-80Z");

svg = `<svg id='selected_order_table' class="tw-w-[18px] tw-h-[18px] tw-inline-block tw-fill-black dark:tw-fill-white" viewBox="0 -960 960 960">
<path d="M440-240v-368L296-464l-56-56 240-240 240 240-56 56-144-144v368h-80Z"/>
</svg>`
}

svg.classList.add("tw-inline-block")
svg.appendChild(path)
// svg.classList.add("tw-inline-block")
// svg.appendChild(path)

return svg
}
Expand Down
8 changes: 7 additions & 1 deletion multisurveys-apis/src/object_api/static/form_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { jdToDate, gregorianToJd, raDectoHMS, HMStoRa, DMStoDec} from "./AstroDa
import { getUTCDate, extractDate, extractTime, convertToDate, formatDate} from "./time.js"
import { handle_error } from "./error_handler.js";
import {draw_oids_tags} from "./draw_elements.js";
import { display, split_oids, format_oids, survey_emphasize, check_radio_consearch } from "./ui_helpers.js";
import { display, highlight_text, split_oids, format_oids, survey_emphasize, check_radio_consearch, switch_arrow_icon } from "./ui_helpers.js";
import {get_sesame_object} from "./sesame.js"
import { send_classes_data, send_pagination_data, send_order_data, clean_nulls_form, get_values_array_fields } from "./api_payload_helpers.js"

Expand Down Expand Up @@ -89,16 +89,22 @@ export function init(){
// clicks events
general_filters.addEventListener("click", () =>{
item_name = general_filters.id + "_container"
switch_arrow_icon(general_filters)
highlight_text(general_filters)
display(item_name)
})

discovery_date_filters.addEventListener("click", () =>{
item_name = discovery_date_filters.id + "_container"
switch_arrow_icon(discovery_date_filters)
highlight_text(discovery_date_filters)
display(item_name)
})

conesearch_filters.addEventListener("click", () =>{
item_name = conesearch_filters.id + "_container"
switch_arrow_icon(conesearch_filters)
highlight_text(conesearch_filters)
display(item_name)
})

Expand Down
Loading