Skip to content

Commit

Permalink
Merge pull request #196 from spacetelescope/release/v0.4.39
Browse files Browse the repository at this point in the history
Release/v0.4.39
  • Loading branch information
raswaters authored Feb 14, 2023
2 parents 2bb0f5d + 34b9377 commit e0ed468
Show file tree
Hide file tree
Showing 41 changed files with 738 additions and 585 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: install requirements
run: |
pip install .[dev]
pip install numpy sklearn tensorflow --upgrade-strategy only-if-needed
pip install numpy scikit-learn tensorflow --upgrade-strategy only-if-needed
- name: run pytest code coverage check
run: |
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
- name: install requirements
run: |
pip install .[dev]
pip install numpy sklearn tensorflow --upgrade-strategy only-if-needed
pip install numpy scikit-learn tensorflow --upgrade-strategy only-if-needed
- name: run pytest
run: pytest -rP
2 changes: 1 addition & 1 deletion calcloud/exit_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
_CODE_TO_NAME = dict()

# Set up original module global variables / named constants
for (name, code) in _EXIT_CODES.items():
for name, code in _EXIT_CODES.items():
globals()[name] = code
_CODE_TO_NAME[code] = name
_CODE_TO_NAME[str(code)] = name
Expand Down
89 changes: 71 additions & 18 deletions calcloud/hst.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# -----------------------------------------------------------------------------

IPPPSSOOT_RE = re.compile(r"^[IJLOijlo][a-zA-Z0-9]{8,8}$")
SVM_RE = re.compile(r"[a-zA-Z0-9]{3,4}_[a-zA-Z0-9]{3}_[a-zA-Z0-9]{2}")
MVM_RE = re.compile(r"skycell-p[0-9]{4}x[0-9]{2}y[0-9]{2}")

# Note: only ACS, COS, STIS, and WFC3 are initially supported
IPPPSSOOT_INSTR = {
Expand All @@ -23,6 +25,35 @@

INSTRUMENTS = set(IPPPSSOOT_INSTR.values())

SVM_INSTRUMENTS = ["acs", "wfc3"]


def get_dataset_type(dataset):
"""Given a dataset name, determine if it's an ipppssoot, SVM, or MVM dataset.
Parameters
----------
dataset : str
Valid Options:
ipppssoot (e.g. ieloc4yzq)
SVM dataset - starts with the instrument name, currently 'acs' or 'wfc3' (e.g. acs_8ph_01)
MVM dataset - starts with 'skycell' (e.g. skycell-p0797x14y06)
Returns
-------
dataset type : str
'ipst', 'svm', or 'mvm'
"""
if IPPPSSOOT_RE.match(dataset):
dataset_type = "ipst"
elif SVM_RE.match(dataset) and dataset.split("_")[0] in SVM_INSTRUMENTS:
dataset_type = "svm"
elif MVM_RE.match(dataset):
dataset_type = "mvm"
else:
raise ValueError("Invalid dataset name, dataset must be an ipppssoot, SVM, or MVM dataset")
return dataset_type


def get_instrument(ipppssoot):
"""Given an `ipppssoot` ID, return the corresponding instrument name.
Expand All @@ -48,28 +79,50 @@ def get_instrument(ipppssoot):
return IPPPSSOOT_INSTR.get(ipppssoot.upper()[0])


# -----------------------------------------------------------------------------


def get_output_path(output_uri, ipppssoot):
"""Given an `output_uri` string which nominally defines an S3 bucket and
directory base path, and an `ipppssoot` dataset name, generate a full
S3 output path where outputs from processing `ipppssoot` should be stored.
def is_dataset_name(dataset):
"""Given a dataset name, determine if it's an HST dataset name (ipppssoot, SVM, or MVM dataset).
Parameters
----------
output_uri : str
A combination of S3 bucket and object directory prefix
ipppssoot : str
HST-style dataset name for which outputs will be stored.
dataset : str
Returns
-------
full_s3_object_path : str
A fully specified S3 object, including bucket, directory, and filename.
>>> get_output_path("s3://temp/batch-2020-02-13T10:33:00", "IC0B02020")
's3://temp/batch-2020-02-13T10:33:00/wfc3/IC0B02020'
is_dataset_name : bool
"""
# This function does not appear to be used anywhere, may have been deprecated
return output_uri + "/" + get_instrument(ipppssoot) + "/" + ipppssoot
if (
IPPPSSOOT_RE.match(dataset)
or (SVM_RE.match(dataset) and dataset.split("_")[0] in SVM_INSTRUMENTS)
or MVM_RE.match(dataset)
):
is_dataset_name = True
else:
is_dataset_name = False
return is_dataset_name


# -----------------------------------------------------------------------------
# 10/12/2022 - Removed get_output_path since it is not used anywhere and appear to be deprecated

# def get_output_path(output_uri, ipppssoot):
# """Given an `output_uri` string which nominally defines an S3 bucket and
# directory base path, and an `ipppssoot` dataset name, generate a full
# S3 output path where outputs from processing `ipppssoot` should be stored.
#
# Parameters
# ----------
# output_uri : str
# A combination of S3 bucket and object directory prefix
# ipppssoot : str
# HST-style dataset name for which outputs will be stored.
#
# Returns
# -------
# full_s3_object_path : str
# A fully specified S3 object, including bucket, directory, and filename.
#
# >>> get_output_path("s3://temp/batch-2020-02-13T10:33:00", "IC0B02020")
# 's3://temp/batch-2020-02-13T10:33:00/wfc3/IC0B02020'
# """
# # This function does not appear to be used anywhere, may have been deprecated
# return output_uri + "/" + get_instrument(ipppssoot) + "/" + ipppssoot
Loading

0 comments on commit e0ed468

Please sign in to comment.