Skip to content

Commit

Permalink
Merge pull request #294 from Subaru-PFS/dev-main
Browse files Browse the repository at this point in the history
Dev main
  • Loading branch information
monodera authored Aug 23, 2024
2 parents efb5bbd + 84e01e8 commit c41fd7c
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 3 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies = [
"mkdocs>=1.4.3",
"multiprocess>=0.70.15",
"myst-parser>=2.0.0",
"numpy<2.0.0",
"pandas>=2.0.3",
"python-dotenv>=1.0.0",
"scikit-learn>=1.3.0",
Expand Down
2 changes: 1 addition & 1 deletion src/pfs_target_uploader/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.0.0"
__version__ = "3.1.0"
23 changes: 22 additions & 1 deletion src/pfs_target_uploader/pn_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from .utils.mail import send_email
from .utils.ppp import ppp_result_reproduce
from .widgets import (
AnnouncementNoteWidgets,
DatePickerWidgets,
DocLinkWidgets,
FileInputWidgets,
Expand Down Expand Up @@ -67,6 +68,17 @@ def target_uploader_app(use_panel_cli=False):
else:
clustering_algorithm = config["CLUSTERING_ALGORITHM"]

if "ANN_FILE" not in config.keys():
ann_file = None
elif config["ANN_FILE"] == "":
ann_file = None
elif not os.path.exists(config["ANN_FILE"]):
logger.error(f"{config['ANN_FILE']} not found")
ann_file = None
else:
logger.info(f"{config['ANN_FILE']} found")
ann_file = config["ANN_FILE"]

logger.info(f"Maximum execution time for the PPP is set to {max_exetime} sec.")
logger.info(f"Maximum number of PPCs is set to {max_nppc}.")

Expand Down Expand Up @@ -124,6 +136,11 @@ def target_uploader_app(use_panel_cli=False):
]

placeholder_floatpanel = pn.Column(height=0, width=0)
placeholder_announcement = pn.Column(height=0, width=0)

if ann_file is not None:
panel_annoucement = AnnouncementNoteWidgets(ann_file)
placeholder_announcement[:] = [panel_annoucement.floatpanel]

# if no file is uploaded, disable the buttons
# This would work only at the first time the app is loaded.
Expand Down Expand Up @@ -252,6 +269,7 @@ def toggle_classical_mode(obs_type):

main_column = pn.Column(
placeholder_floatpanel,
placeholder_announcement,
tab_panels,
margin=(30, 0, 0, 0),
)
Expand Down Expand Up @@ -687,7 +705,10 @@ def Table_files_tgt_psl(column_checkbox_):
frozen_columns=["index"],
pagination="remote",
header_filters=True,
buttons={"magnify": "<i class='fa-solid fa-magnifying-glass'></i>", "download": "<i class='fa-solid fa-download'></i>"},
buttons={
"magnify": "<i class='fa-solid fa-magnifying-glass'></i>",
"download": "<i class='fa-solid fa-download'></i>",
},
layout="fit_data_table",
hidden_columns=_hidden_columns,
disabled=True,
Expand Down
2 changes: 1 addition & 1 deletion src/pfs_target_uploader/utils/ppp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ def ppp_plotFig(RESmode, cR, sub, obj_allo, uS):
"Point_" + RESmode + "_" + str(count)
for count in (np.arange(0, len(obj_allo), 1) + 1)
]

obj_allo1 = obj_allo1.group_by("ppc_code")
obj_allo1.rename_column("tel_fiber_usage_frac", "Fiber usage fraction (%)")
obj_allo2 = Table.to_pandas(obj_allo1)
Expand Down
30 changes: 30 additions & 0 deletions src/pfs_target_uploader/widgets/AnnouncementNoteWidgets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python3

import os

import panel as pn


class AnnouncementNoteWidgets:
def __init__(self, ann_file=None):
if ann_file is not None:

with open(ann_file, "r") as f:
message = f.read()

self.floatpanel = pn.layout.FloatPanel(
message,
name="Important Updates for Users",
config={
"headerLogo": "<i style='margin-left: 0.5em;' class='fa-solid fa-circle-info fa-lg'></i>",
},
contained=False,
position="center",
# theme="danger",
# theme="#3A7D7E",
theme="#DB2955",
margin=20,
# margin=100,
width=720,
# height=350,
)
2 changes: 2 additions & 0 deletions src/pfs_target_uploader/widgets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3

from .AnnouncementNoteWidgets import AnnouncementNoteWidgets
from .buttons import RunPppButtonWidgets, SubmitButtonWidgets, ValidateButtonWidgets
from .DatePickerWidgets import DatePickerWidgets
from .DocLinkWidgets import DocLinkWidgets
Expand Down Expand Up @@ -30,4 +31,5 @@
"TargetWidgets",
"UploadNoteWidgets",
"ValidationResultWidgets",
"AnnouncementNoteWidgets",
]

0 comments on commit c41fd7c

Please sign in to comment.