Skip to content

Commit

Permalink
Merge branch 'develop' into specify-pids-for-preview-image-creation
Browse files Browse the repository at this point in the history
  • Loading branch information
mfixstsci authored Jul 13, 2024
2 parents b440941 + e183ff0 commit df3d8f5
Show file tree
Hide file tree
Showing 15 changed files with 181 additions and 38 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ jobs:
build:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@v1
with:
upload_to_pypi: false
upload_to_pypi: ${{ (github.event_name == 'release') && (github.event.action == 'released') }}
secrets:
pypi_token: ${{ secrets.PYPI_PASSWORD_STSCI_MAINTAINER }}
freeze:
runs-on: ${{ matrix.os }}
strategy:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ jwql/website/apps/jwql/static/filesystem
jwql/website/apps/jwql/static/outputs
jwql/website/apps/jwql/static/preview_images
jwql/website/apps/jwql/static/thumbnails
jwql-current.yml
41 changes: 41 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
## What's Changed

1.2.10 (2024-07-10)
===================

Duplicate of 1.2.9, caused by changes to versioning conflicts with pypi.


1.2.9 (2024-07-10)
==================

Web Application
~~~~~~~~~~~~~~~
- Add Download CSV button to query page by @BradleySappington in https://github.com/spacetelescope/jwql/pull/1561
- show file anomalies on exposure group page by @BradleySappington in https://github.com/spacetelescope/jwql/pull/1564
- create generic error page to handle exceptions in views. by @BradleySappington in https://github.com/spacetelescope/jwql/pull/1549

Project & API Documentation
~~~~~~~~~~~~~~~~~~~~~~~~~~~
- final model define for faking by @BradleySappington in https://github.com/spacetelescope/jwql/pull/1544
- Update Redis Package Names in Environment Files by @mfixstsci in https://github.com/spacetelescope/jwql/pull/1546
- [SCSB-145] require Python 3.10 by @zacharyburnett in https://github.com/spacetelescope/jwql/pull/1515
- debug false by default by @BradleySappington in https://github.com/spacetelescope/jwql/pull/1550
- Update NIRSpec TA Monitors to use Django DB Models by @mfixstsci in https://github.com/spacetelescope/jwql/pull/1499
- Update NIRSpec TA Models by @mfixstsci in https://github.com/spacetelescope/jwql/pull/1565
- Remove codecov.yml by @bhilbert4 in https://github.com/spacetelescope/jwql/pull/1588
- Remove filename parser test over filesystem by @bhilbert4 in https://github.com/spacetelescope/jwql/pull/1586
- Update remote to upstream in pull_jwql_branch.sh by @bhilbert4 in https://github.com/spacetelescope/jwql/pull/1591
- Add Dependencies for Servers in `pyproject.toml` by @mfixstsci in https://github.com/spacetelescope/jwql/pull/1568
- fix release upload step condition to match workflow trigger by @zacharyburnett in https://github.com/spacetelescope/jwql/pull/1593
- fix environment freeze workflow not picking up tag by @zacharyburnett in https://github.com/spacetelescope/jwql/pull/1594
- fix version matching pattern by @zacharyburnett in https://github.com/spacetelescope/jwql/pull/1595
- updating freeze matrix to include linux, mac and python 3.12 by @mfixstsci in https://github.com/spacetelescope/jwql/pull/1596
- Remove P750L from list of NIRSpec filters by @bhilbert4 in https://github.com/spacetelescope/jwql/pull/1598
- [build] fix `runs-on:` and update build filename for easier parsing by @zacharyburnett in https://github.com/spacetelescope/jwql/pull/1599
- upload to PyPI on release by @zacharyburnett in https://github.com/spacetelescope/jwql/pull/1601
- Updating jwst_reffiles version number by @mfixstsci in https://github.com/spacetelescope/jwql/pull/1606
- Remove old presentations from repo by @bhilbert4 in https://github.com/spacetelescope/jwql/pull/1607
- Num results fix by @BradleySappington in https://github.com/spacetelescope/jwql/pull/1608
- Add Environment Update Script by @mfixstsci in https://github.com/spacetelescope/jwql/pull/1609
- Add new NIRISS AMI-related suffixes by @bhilbert4 in https://github.com/spacetelescope/jwql/pull/1613


1.2.8 (2024-04-18)
==================

Expand Down
70 changes: 70 additions & 0 deletions jwql/install-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
branchname=$1
python_version=$2

printf "UPDATING JWQL ENVIRONMENT\n\n"

# Check operating system to obtain proper substring for environment
if [[ "$OSTYPE" == "darwin"* ]]; then
os_str="macOS_ARM64"
printf "INFORMATION: \n \t MAC OS DETECTED, USING MAC ENVIRONMENT FILE\n"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
os_str="Linux_X64"
printf "INFORMATION: \n \t LINUX OS DETECTED, USING LINUX ENVIRONMENT FILE\n"
else
printf "EXCEPTION: \n \t $OSTYPE NOT SUPPORTED, EXITING"
return
fi

# Check if branch name starts with "v" for our major releases
# Our branch names contain v prior to version number, but version names on git
# do not contain v prior to the number.
if [[ $branchname == v* ]]; then
jwql_version=${branchname:1:${#branchname}}
environment_url=https://github.com/spacetelescope/jwql/releases/download/$jwql_version/
environment_name=jwql_${jwql_version}_conda_${os_str}_py${python_version}
environment_filename="${environment_name}.yml"
else
printf "EXCEPTION: \n \t RELEASE DOESNT FOLLOW RELEASE VERSIONING NAMING CONVENTION, EXITING"
return
fi

# Download asset from release and install it.
if curl --head --silent --fail "${environment_url}${environment_filename}" 2> /dev/null;
then
# Reset back to base first before generating environment (incase one is currently activated)
eval "$(conda shell.bash deactivate)"
eval "$(conda shell.bash activate base)"
printf "\n SUCESSFULLY LOCATED ENVIRONMENT FILE ${environment_url}${environment_filename} \n"
curl -L "${environment_url}/${environment_filename}" > jwql-current.yml
$CONDA_EXE env create --name $environment_name --file jwql-current.yml
else
printf "EXCEPTION:\n"
printf "\t ${environment_url}${environment_filename} DOES NOT EXIST, EXITING\n"
printf "\t \nENSURE THAT: \n"
printf "\t https://github.com/spacetelescope/jwql/releases/tag/$branchname \n"
printf "EXISTS AND VERIFY ASSET FOR ${jwql_version}, ${python_version} FOR OS ${os_str}"
return
fi

# Update symlink
cd ${CONDA_PREFIX}/envs/

env_symlink="jwql-current"

if [[ -L $env_symlink || -e $env_symlink ]]; then
printf "INFORMATION:\n"
printf "\tjwql-current SYMLINK EXISTS, UNLINKING\n"
unlink jwql-current
fi

printf "INFORMATION:\n\tLINKING NEW ENVIRONMENT\n"
ln -s $environment_name jwql-current

printf "\tjwql-current HAS BEEN SET TO: ${environment_name}\n"
printf "\tTO SEE CHANGES, EXIT/RESTART SHELL\n"

# return to original directory
cd -

# Conda commands change shell prompt, this just returns it to the default
export PS1="\n(base)\h:\W \u\$ "
2 changes: 1 addition & 1 deletion jwql/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@
]

# Possible suffix types for AMI files
NIRISS_AMI_SUFFIX_TYPES = ["amiavg", "aminorm", "ami", "psf-amiavg"]
NIRISS_AMI_SUFFIX_TYPES = ["amiavg", "aminorm", "ami", "psf-amiavg", "psf-ami-oi", "ami-oi", "aminorm-oi", "amimulti-oi", "amilg"]

# Determine if the code is being run as part of CI checking on github
ON_GITHUB_ACTIONS = '/home/runner' in os.path.expanduser('~') or '/Users/runner' in os.path.expanduser('~')
Expand Down
48 changes: 43 additions & 5 deletions jwql/utils/preview_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,16 +490,54 @@ def make_figure(self, image, integration_number, min_value, max_value,
dig = 2
format_string = "%.{}f".format(dig)
tlabelstr = [format_string % number for number in tlabelflt]
cbar = self.fig.colorbar(cax, ticks=tickvals)

# This seems to correctly remove the ticks and labels we want to remove. It gives a warning that
# it doesn't work on log scales, which we don't care about. So let's ignore that warning.
warnings.filterwarnings("ignore", message="AutoMinorLocator does not work with logarithmic scale")
cbar.ax.yaxis.set_minor_locator(AutoMinorLocator(n=0))

cbar.ax.set_yticklabels(tlabelstr)
cbar.ax.tick_params(labelsize=maxsize * 5. / 4)
cbar.ax.set_ylabel(self.units, labelpad=10, rotation=270)
xyratio = xsize / ysize
if xyratio < 1.6:
# For apertures that are taller than they are wide, square, or that are wider than
# they are tall but still reasonably close to square, put the colorbar on the right
# side of the image.

# Some magic numbers arrived at through testing aspect ratios for all apertures
if xyratio > 0.4:
cb_width = 0.05
else:
cb_width = 0.05 * 0.4 / xyratio

upper_x_anchor = 0.02
if xyratio < 0.1:
upper_x_anchor = 0.12

cbax = self.fig.add_axes([ax.get_position().x1 + upper_x_anchor,
ax.get_position().y0,
cb_width,
ax.get_position().height
])
cbar = self.fig.colorbar(cax, cax=cbax, ticks=tickvals, orientation='vertical')
cbar.ax.yaxis.set_minor_locator(AutoMinorLocator(n=0))
cbar.ax.set_yticklabels(tlabelstr)
cbar.ax.set_ylabel(self.units, labelpad=7, rotation=270)
else:
# For apertures that are significantly wider than they are tall, put the colorbar
# under the image.

# Again, some magic numbers controlling the positioning and height of the
# colorbar, based on testing.
lower_y_anchor = 0. - (xyratio / 14.5)
cb_height = 0.07 * (np.log2(xyratio) - 1)

cbax = self.fig.add_axes([ax.get_position().x0,
ax.get_position().y0 + lower_y_anchor,
ax.get_position().width,
cb_height])
cbar = self.fig.colorbar(cax, cax=cbax, ticks=tickvals, orientation='horizontal')
cbar.ax.xaxis.set_minor_locator(AutoMinorLocator(n=0))
cbar.ax.set_xticklabels(tlabelstr)
cbar.ax.set_xlabel(self.units, labelpad=7, rotation=0)

ax.set_xlabel('Pixels', fontsize=maxsize * 5. / 4)
ax.set_ylabel('Pixels', fontsize=maxsize * 5. / 4)
ax.tick_params(labelsize=maxsize)
Expand Down
3 changes: 2 additions & 1 deletion jwql/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,8 @@ def filename_parser(filename):
time_series,
time_series_2c,
guider,
guider_segment]
guider_segment
]

filename_type_names = [
'stage_1_and_2',
Expand Down
2 changes: 1 addition & 1 deletion jwql/website/apps/jwql/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class JwqlQueryForm(BaseForm):
num_choices = [(50, 50), (100, 100), (200, 200), (500, 500)]
num_per_page = forms.ChoiceField(
required=True,
choices=num_choices, initial=num_choices[1],
choices=num_choices, initial=num_choices[3],
widget=forms.RadioSelect)

# instrument specific parameters
Expand Down
1 change: 1 addition & 0 deletions jwql/website/apps/jwql/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def jwql_query(request):
parameters[QueryConfigKeys.DATE_RANGE] = form.cleaned_data['date_range']
parameters[QueryConfigKeys.PROPOSAL_CATEGORY] = form.cleaned_data['proposal_category']
parameters[QueryConfigKeys.SORT_TYPE] = form.cleaned_data['sort_type']
parameters[QueryConfigKeys.NUM_PER_PAGE] = form.cleaned_data['num_per_page']
parameters[QueryConfigKeys.ANOMALIES] = all_anomalies
parameters[QueryConfigKeys.APERTURES] = all_apers
parameters[QueryConfigKeys.FILTERS] = all_filters
Expand Down
Binary file removed presentations/jwql_presentation.pdf
Binary file not shown.
Binary file removed presentations/jwql_tips_2019_07.pdf
Binary file not shown.
Binary file removed presentations/jwql_web_app.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies = [
"jsonschema>=4.21.1,<5",
"jwst>=1.13.4,<2",
"jwst_backgrounds>=1.2.0,<1.3.0",
"jwst_reffiles@git+https://github.com/spacetelescope/jwst_reffiles",
"jwst_reffiles>=1.0.1",
"matplotlib>=3.8.3,<4",
"numpy>=1.26.4,<2",
"pandas>=2.2.1,<3",
Expand Down
36 changes: 13 additions & 23 deletions style_guide/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

# Global variables should be avoided, but if used should be named with
# all-caps
A_GLOBAL_VARIABLE = 'foo' # type: str
A_GLOBAL_VARIABLE = "foo" # type: str


@log_fail
Expand All @@ -92,14 +92,14 @@ def my_main_function(path: str, filter: str) -> None:
The filter to process (e.g. "F606W").
"""

logging.info('Using {} as an input file'.format(path))
logging.info("Using {} as an input file".format(path))

an_int = 1 # type: int
a_float = 3.14 # type: float
a_bool = True # type: bool
a_list = ['Dog', 'Cat', 'Turtle', False, 7] # type: List[Union[str, bool, int]]
a_tuple = ('Dog', 'Cat', 'Turtle', False, 7) # type: Tuple[str, str, str, bool, int]
a_dict = {'key1': 'value1', 'key2': 'value2'} # type: Dict[str, str]
a_list = ["Dog", "Cat", "Turtle", False, 7] # type: List[Union[str, bool, int]]
a_tuple = ("Dog", "Cat", "Turtle", False, 7) # type: Tuple[str, str, str, bool, int]
a_dict = {"key1": "value1", "key2": "value2"} # type: Dict[str, str]
an_obj = object() # type: object

result = some_other_function(an_int, a_float, a_bool, a_list, a_tuple, a_dict, an_obj) # type: Optional[int]
Expand All @@ -117,21 +117,13 @@ def parse_args() -> argparse.Namespace:
"""

# Create help strings
path_help = 'The path to the input file.' # type: str
path_help = "The path to the input file." # type: str
filter_help = 'The filter to process (e.g. "F606W").' # type: str

# Add arguments
parser = argparse.ArgumentParser() # type: argparse.ArgumentParser
parser.add_argument('path',
type=str,
default=os.getcwd(),
help=path_help)
parser.add_argument('-f --filter',
dest='filter',
type=str,
required=False,
default='F606W',
help=filter_help)
parser.add_argument("path", type=str, default=os.getcwd(), help=path_help)
parser.add_argument("-f --filter", dest="filter", type=str, required=False, default="F606W", help=filter_help)

# Parse args
args = parser.parse_args() # type: argparse.Namespace
Expand All @@ -140,8 +132,7 @@ def parse_args() -> argparse.Namespace:


@log_timing
def some_other_function(an_int: int, a_float: float, a_bool: bool, a_list: List[Any],
a_tuple: Tuple[Any], a_dict: Dict[Any, Any], an_obj: object) -> int:
def some_other_function(an_int: int, a_float: float, a_bool: bool, a_list: List[Any], a_tuple: Tuple[Any], a_dict: Dict[Any, Any], an_obj: object) -> int:
"""This function just does a bunch of nonsense.
But it serves as a decent example of some things.
Expand Down Expand Up @@ -170,19 +161,18 @@ def some_other_function(an_int: int, a_float: float, a_bool: bool, a_list: List[
"""

# File I/O should be handeled with 'with open' when possible
with open('my_file', 'w') as f:
f.write('My favorite integer is {}'.format(an_int))
with open("my_file", "w") as f:
f.write("My favorite integer is {}".format(an_int))

# Operators should be separated by spaces
logging.info(a_float + a_float)

return an_int


if __name__ == '__main__':

if __name__ == "__main__":
# Configure logging
module = os.path.basename(__file__).strip('.py')
module = os.path.basename(__file__).strip(".py")
configure_logging(module)

args = parse_args() # type: argparse.Namespace
Expand Down
9 changes: 4 additions & 5 deletions style_guide/typing_demo/typing_demo_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"""

import sys
from typing import (List, Set, Dict, Tuple, Union, Optional, Callable,
Iterable, Any)
from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Tuple, Union

assert sys.version_info >= (3, 6) # PEP 526 added variable annotations

Expand All @@ -18,7 +17,7 @@
a_string: str = "jwql"
a_list: List[int] = [1]
a_set: Set[int] = {1, 2, 3}
a_dict: Dict[str, bool] = {'jwql': True} # Have to specify both keys and values
a_dict: Dict[str, bool] = {"jwql": True} # Have to specify both keys and values

# For python versions prior to 3.6, the variable annotation syntax uses comments:
# annotated_variable = 1 # type: int
Expand Down Expand Up @@ -68,6 +67,7 @@ def a_generator() -> Iterable[int]:
# Type annotations are stored in __annotations__, either as a local variable
# or as an object attribute.


def print_annotations(arg: Any) -> bool:
if not hasattr(arg, "__annotations__"):
print("Sorry, that argument doesn't have its own __annotations__.")
Expand All @@ -76,8 +76,7 @@ def print_annotations(arg: Any) -> bool:
return bool(arg.__annotations__)


for name in ["an_integer", "a_generic_function", "two_arg_function",
"func_alias", "anon_func", "a_generator"]:
for name in ["an_integer", "a_generic_function", "two_arg_function", "func_alias", "anon_func", "a_generator"]:
var = locals()[name]
print(f"Annotations for {name}:")
if not print_annotations(var):
Expand Down

0 comments on commit df3d8f5

Please sign in to comment.