Skip to content
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

bugfix/astroquery-import #49

Merged
merged 10 commits into from
Apr 2, 2024
Merged
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
10 changes: 10 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
1.0.1 (unreleased)
==================

bugfixes
--------

- move HstSvmRadio import inside class method to avoid importing astroquery unnecessarily [#49]

- temporarily pin tf max version to 2.15 to ensure compatibility with models saved in 2.13 or older

- matplotlib style setting looks for "seaborn-v0_8-bright" if "seaborn-bright" unavailable, fallback uses default style


installation / automation
-------------------------

Expand Down
3 changes: 0 additions & 3 deletions docker/images/dashboard_image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ RUN apt update && \
apt upgrade --assume-yes && \
ACCEPT_EULA=Y DEBIAN_FRONTEND=noninteractive && \
apt install --assume-yes \
# wget \
# make \
sudo \
git \
vim \
Expand Down Expand Up @@ -42,7 +40,6 @@ RUN python3 -m venv /home/developer/venv && \
dash~=2.0.0 \
dash-cytoscape \
dash-daq && \
pip uninstall werkzeug -y && pip install werkzeug==2.0.3 && \
mkdir /home/developer/data && \
python -m spacekit.datasets.beam -s="${SRC}:${COLLECTION}" -d=$DATASETS -o=$SPACEKIT_DATA

Expand Down
2 changes: 1 addition & 1 deletion docs/source/skopes/hst/cal/predict.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*******************************
spacekit.skopes.hst.svm.predict
spacekit.skopes.hst.cal.predict
*******************************

.. currentmodule:: spacekit.skopes.hst.cal.predict
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ exclude = [
'dist',
'.egg',
]

[tool.ruff.lint]
ignore = [
'E741', # ambiguous variable name
]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
'spacekit/preprocessor/scrub.py' = ['E712']
2 changes: 0 additions & 2 deletions scripts/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ fi

if [ $MOUNTS -ne 0 ]; then
docker run ${CONTAINER_MODE} --name $NAME \
--ip $IPADDRESS --hostname $HOSTNAME -p 8050:8050 $* \
--mount type=bind,source=${SOURCEDATA},target=${DESTDATA} \
$DOCKER_IMAGE $EPCOMMAND
else
docker run ${CONTAINER_MODE} --name $NAME \
--ip $IPADDRESS --hostname $HOSTNAME -p 8050:8050 $* \
$DOCKER_IMAGE $EPCOMMAND
fi
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = spacekit
version = 1.0.0
version = 1.0.1
author = Ru Keïn
author_email = [email protected]
license = MIT
Expand Down Expand Up @@ -35,7 +35,7 @@ setup_requires =
setuptools >=42

install_requires =
tensorflow>=2.7
tensorflow<2.16
astropy
boto3
numpy>=1.19
Expand Down
9 changes: 7 additions & 2 deletions spacekit/analyzer/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@
import plotly.graph_objects as go
import matplotlib as mpl
import matplotlib.pyplot as plt

plt.style.use("seaborn-bright")
font_dict = {"family": "monospace", "size": 16} # Titillium Web
mpl.rc("font", **font_dict)
styles = ["seaborn-bright", "seaborn-v0_8-bright"]
valid_styles = [s for s in styles if s in plt.style.available]
if len(valid_styles) > 0:
try:
plt.style.use(valid_styles[0])
except OSError:
pass
except ImportError:
go = None
mpl = None
Expand Down
9 changes: 7 additions & 2 deletions spacekit/analyzer/explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@
try:
import matplotlib as mpl
import matplotlib.pyplot as plt

plt.style.use("seaborn-bright")
font_dict = {"family": "monospace", "size": 16}
mpl.rc("font", **font_dict)
styles = ["seaborn-bright", "seaborn-v0_8-bright"]
valid_styles = [s for s in styles if s in plt.style.available]
if len(valid_styles) > 0:
try:
plt.style.use(valid_styles[0])
except OSError:
pass
except ImportError:
mpl = None
plt = None
Expand Down
6 changes: 3 additions & 3 deletions spacekit/extractor/radio.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
from astroquery.mast import Observations
except ImportError:
Observations = None

try:
from progressbar import ProgressBar
except ImportError:
ProgressBar = None


def check_astroquery():
return Observations is not None

Expand All @@ -25,9 +25,9 @@ def check_progressbar():


def check_imports():
if not check_astroquery():
if not check_progressbar():
return False
elif not check_progressbar():
elif not check_astroquery():
return False
else:
return True
Expand Down
10 changes: 7 additions & 3 deletions spacekit/preprocessor/scrub.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
JwstFitsScraper,
scrape_catalogs,
)
from spacekit.extractor.radio import HstSvmRadio
from spacekit.preprocessor.encode import HstSvmEncoder, JwstEncoder, encode_booleans
from spacekit.logger.log import Logger

Expand Down Expand Up @@ -190,6 +189,11 @@ def __init__(
self.make_subsamples = make_subsamples
self.set_new_cols()
self.set_prefix_cols()
self.initialize_radio()

def initialize_radio(self):
from spacekit.extractor.radio import HstSvmRadio
self.radio = HstSvmRadio

def preprocess_data(self):
"""Main calling function to run each preprocessing step for SVM regression data."""
Expand All @@ -200,7 +204,7 @@ def preprocess_data(self):
n_retries = 3
while n_retries > 0:
try:
self.df = HstSvmRadio(self.df).scrape_mast()
self.df = self.radio(self.df).scrape_mast()
n_retries = 0
except Exception as e:
self.log.warning(e)
Expand Down Expand Up @@ -262,7 +266,7 @@ def scrub_qa_data(self):
self.scrub_columns()
# STAGE 2 initial encoding
self.df = SvmFitsScraper(self.df, self.input_path).scrape_fits()
self.df = HstSvmRadio(self.df).scrape_mast()
self.df = self.radio(self.df).scrape_mast()

def scrub_qa_summary(self, csvfile="single_visit_mosaics*.csv", idx=0):
"""Alternative if no .json files available (QA step not run during processing)"""
Expand Down
8 changes: 4 additions & 4 deletions tests/skopes/hst/cal/test_hst_cal_predict.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
from pytest import mark
from moto import mock_s3
from moto import mock_aws
from spacekit.skopes.hst.cal.predict import local_handler, lambda_handler
import boto3

Expand All @@ -27,7 +27,7 @@ def put_moto_s3_object(dataset, bucketname):
@mark.cal
@mark.predict
@mark.parametrize("pipeline", [("asn")])
@mock_s3
@mock_aws
def test_local_predict_handler(hst_cal_predict_visits, pipeline):
bucketname = "spacekit_bucket"
s3 = boto3.resource("s3", region_name="us-east-1")
Expand All @@ -43,7 +43,7 @@ def test_local_predict_handler(hst_cal_predict_visits, pipeline):
@mark.cal
@mark.predict
@mark.parametrize("pipeline", [("asn")])
@mock_s3
@mock_aws
def test_local_handler_multiple(hst_cal_predict_visits, pipeline):
bucketname = "spacekit_bucket"
s3 = boto3.resource("s3", region_name="us-east-1")
Expand All @@ -62,7 +62,7 @@ def test_local_handler_multiple(hst_cal_predict_visits, pipeline):
@mark.cal
@mark.predict
@mark.parametrize("pipeline", [("asn")])
@mock_s3
@mock_aws
def test_lambda_handler(hst_cal_predict_visits, pipeline):
bucketname = "spacekit_bucket"
s3 = boto3.resource("s3", region_name="us-east-1")
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ skip_install = true
changedir = .
description = check code style with ruff
deps = ruff
commands = ruff . {posargs}
commands = ruff check . {posargs}

[testenv:check-security]
skip_install = true
Expand Down
Loading