Skip to content

Commit

Permalink
Merge pull request #91 from WilliamJamieson/refactor/remove_stdatamodels
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamJamieson committed Apr 14, 2023
2 parents 5859cfb + bc755f6 commit cfe96d7
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 37 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

- Remove use of deprecated ``pytest-openfiles`` ``pytest`` plugin. This has been replaced by
catching ``ResourceWarning`` s. [#90]

- Start using ``pre-commit`` to handle style checks. [#79]
- Apply the ``isort`` and ``black`` code formatters and reduce the line length
maximum to 88 characters. [#80]
- Add spell checking through the ``codespell`` tool. [#81]
- Drop support for Python 3.8 [#93]
- Remove ``stdatamodels`` dependency, as it is no longer used. [#91]

0.4.6 (2023-03-27)
==================
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencies = [
'asdf>=2.13',
'crds>=7.4.1.3',
'astropy>=5.0.4',
'stdatamodels>=0.2.4',
'importlib_metadata>=4.11.4',
]
dynamic = ['version']
Expand Down
24 changes: 0 additions & 24 deletions src/stpipe/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from asdf import ValidationError as AsdfValidationError
from asdf import open as asdf_open
from stdatamodels import s3_utils

from . import utilities
from .config import StepConfig
Expand Down Expand Up @@ -102,13 +101,6 @@ def load_config_file(config_file):
"""
Read the file `config_file` and return the parsed configuration.
"""
if s3_utils.is_s3_uri(config_file):
return _load_config_file_s3(config_file)
else:
return _load_config_file_filesystem(config_file)


def _load_config_file_filesystem(config_file):
if not os.path.isfile(config_file):
raise ValueError(f"Config file {config_file} not found.")
try:
Expand All @@ -121,22 +113,6 @@ def _load_config_file_filesystem(config_file):
return ConfigObj(config_file, raise_errors=True)


def _load_config_file_s3(config_file):
if not s3_utils.object_exists(config_file):
raise ValueError(f"Config file {config_file} not found.")

content = s3_utils.get_object(config_file)
try:
with asdf_open(content) as asdf_file:
return _config_obj_from_asdf(asdf_file)
except (AsdfValidationError, ValueError):
logger.debug(
"Config file did not parse as ASDF. Trying as ConfigObj: %s", config_file
)
content.seek(0)
return ConfigObj(content, raise_errors=True)


def _config_obj_from_asdf(asdf_file):
config = StepConfig.from_asdf(asdf_file)
return _config_obj_from_step_config(config)
Expand Down
11 changes: 3 additions & 8 deletions src/stpipe/crds_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import crds
from crds.core import config, crds_cache_locking, heavy_client, log
from crds.core.exceptions import CrdsError
from stdatamodels import s3_utils

__all__ = [
"check_reference_open",
Expand All @@ -33,7 +32,7 @@ def get_multiple_reference_paths(parameters, reference_file_types, observatory):
----------
parameters : dict
Parameters used by CRDS to compute best references. Can
be obtained from `~stdatamodels.DataModel.get_crds_parameters`.
be obtained from `DataModel.get_crds_parameters`.
reference_file_types : list of str
List of reference file types.
Expand Down Expand Up @@ -81,12 +80,8 @@ def check_reference_open(refpath):
Ignore reference path values of "N/A" or "" for checking.
"""
if refpath != "N/A" and refpath.strip() != "":
if s3_utils.is_s3_uri(refpath):
if not s3_utils.object_exists(refpath):
raise RuntimeError("S3 object does not exist: " + refpath)
else:
with open(refpath, "rb"):
pass
with open(refpath, "rb"):
pass
return refpath


Expand Down
3 changes: 0 additions & 3 deletions src/stpipe/extern/configobj/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@

import re
import sys
from pprint import pprint

from stdatamodels import DataModel

#TODO - #21 - six is part of the repo now, but we didn't switch over to it here
# this could be replaced if six is used for compatibility, or there are no
Expand Down

0 comments on commit cfe96d7

Please sign in to comment.