Skip to content

Commit

Permalink
RCAL-644 Remove checks on CI in production code (#955)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
stscieisenhamer and pre-commit-ci[bot] authored Oct 27, 2023
1 parent 10e90bd commit 13c316e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 13 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ resample
--------
- Implement resampling step. [#787]

stpipe
------

- Remove checks on CI in production code [#955]

tweakreg
--------

Expand Down
19 changes: 6 additions & 13 deletions romancal/stpipe/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@
Roman Calibration Pipeline base class
"""
import logging
import os
import time

import roman_datamodels as rdm
from roman_datamodels.datamodels import ImageModel
from stpipe import Pipeline, Step
from stpipe import Pipeline, Step, crds_client

from ..lib.suffix import remove_suffix

if os.environ.get("CI") == "false":
from stpipe import crds_client


_LOG_FORMATTER = logging.Formatter(
"%(asctime)s.%(msecs)03dZ :: %(name)s :: %(levelname)s :: %(message)s",
datefmt="%Y-%m-%dT%H:%M:%S",
Expand Down Expand Up @@ -67,13 +62,11 @@ def finalize_result(self, model, reference_files_used):

# this will only run if 'parent' is none, which happens when an individual
# step is being run or if self is a RomanPipeline and not a RomanStep.

if os.environ.get("CI") == "false": # no CRDS connection, do not run
if self.parent is None:
model.meta.ref_file.crds.sw_version = crds_client.get_svn_version()
model.meta.ref_file.crds.context_used = crds_client.get_context_used(
model.crds_observatory
)
if self.parent is None:
model.meta.ref_file.crds.sw_version = crds_client.get_svn_version()
model.meta.ref_file.crds.context_used = crds_client.get_context_used(
model.crds_observatory
)

def record_step_status(self, model, step_name, success=True):
"""
Expand Down
26 changes: 26 additions & 0 deletions romancal/stpipe/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from astropy.time import Time
from roman_datamodels.datamodels import FlatRefModel, ImageModel
from roman_datamodels.maker_utils import mk_level2_image
from stpipe import crds_client

from romancal.stpipe import RomanPipeline, RomanStep

Expand Down Expand Up @@ -90,3 +91,28 @@ def process(self):

result = LoggingStep().run()
assert any("Splines failed to reticulate" in l for l in result.cal_logs)


@pytest.mark.skipif(
os.environ.get("CI") == "true",
reason=(
"Roman CRDS servers are not currently available outside the internal network"
),
)
def test_crds_meta():
"""Test that context and software versions are set"""

class ReflectStep(RomanStep):
def process(self, input):
return input

im = ImageModel(mk_level2_image(shape=(20, 20)))
im.meta.ref_file.crds.sw_version = "junkversion"
im.meta.ref_file.crds.context_used = "junkcontext"

result = ReflectStep.call(im)

assert result.meta.ref_file.crds.sw_version == crds_client.get_svn_version()
assert result.meta.ref_file.crds.context_used == crds_client.get_context_used(
result.crds_observatory
)

0 comments on commit 13c316e

Please sign in to comment.