Skip to content
Snippets Groups Projects
Commit 5e27f97d authored by Charlotte Hausman's avatar Charlotte Hausman
Browse files

Fixing manifest generation

parent 4fdd6314
No related branches found
No related tags found
1 merge request!409Fixing manifest generation
Pipeline #2462 passed
......@@ -2,6 +2,8 @@
from pathlib import Path
from typing import List
import logging
from ingest_envoy.manifest_components import (
OutputScienceProduct,
AncillaryProduct,
......@@ -12,6 +14,8 @@ from ingest_envoy.utilities import AncillaryProductType
FITS = "fits"
RMS = "rms"
PB = "pb"
MASK = "mask"
# pylint: disable=R1721
......@@ -19,6 +23,7 @@ class ImageIngestionProductsFinder:
"""Finds ancillary science products and other ancillary products needed for image ingestion"""
def __init__(self, staging_source_dir: Path):
self.logger = logging.getLogger("ingest_envoy")
self.staging_source_dir = staging_source_dir
self.files_found = [file for file in self.staging_source_dir.iterdir()]
self.output_science_products = self._find_output_science_products()
......@@ -40,14 +45,21 @@ class ImageIngestionProductsFinder:
:return:
"""
sp_image_file = [
file for file in self.files_found if file.name.endswith(FITS) and RMS not in file.name
file
for file in self.files_found
if file.name.endswith(FITS)
and RMS not in file.name
and PB not in file.name
and MASK not in file.name
][0]
self.logger.info(f"Science Product to ingest is: {sp_image_file.name}")
image_files = [
file
for file in self.files_found
if (file.name.endswith(FITS) or file.name.endswith(".png"))
and file.name != sp_image_file.name
]
self.logger.info(f"Science Product ancillaries are: {image_files}")
sp_aps = []
for image_file in image_files:
......@@ -104,20 +116,20 @@ class ImageIngestionProductsFinder:
:param file: a possible ancillary image product
:return: the corresponding AncillaryProduct, if applicable
"""
filename = str(file)
if "image" in file.name:
filename = file.name
if "image" in filename:
if filename.endswith(".png"):
return AncillaryProduct(type=AncillaryProductType.THUMBNAIL_IMG, filename=filename)
if filename.endswith(FITS) and RMS in file.name:
if filename.endswith(FITS) and RMS in filename:
return AncillaryProduct(
type=AncillaryProductType.QUICKLOOK_RMS_IMAGE, filename=filename
)
return AncillaryProduct(type=AncillaryProductType.QUICKLOOK_IMAGE, filename=filename)
if filename.endswith(FITS):
if "pb" in filename:
if PB in filename:
return AncillaryProduct(type=AncillaryProductType.PB_FITS, filename=filename)
if "band" in filename:
return AncillaryProduct(type=AncillaryProductType.FITS, filename=filename)
if MASK in filename:
return AncillaryProduct(type=AncillaryProductType.FITS_MASK, filename=filename)
# TODO: what might it be?
raise ValueError(f"don't know what type of image '{filename}' is")
......
......@@ -99,10 +99,20 @@ class VelaProduct:
path = Path.cwd() / "products"
os.chdir(path)
filename = "oussid.J1106-3646_sci.X.pb.tt0.fits"
pb_filename = "oussid.1-93305_sci.L_band.cont.I.pb.tt0.fits"
cont_filename = "oussid.1-93305_sci.L_band.cont.I.tt0.fits"
mask_filename = "oussid.1-93305_sci.L_band.cont.I.mask.fits"
fits = open(filename, "x")
fits.write("I am an image.")
fits = open(pb_filename, "x")
fits.write("I am a primary beam image.")
fits.close()
fits = open(cont_filename, "x")
fits.write("I am a continuum image.")
fits.close()
fits = open(mask_filename, "x")
fits.write("I am a mask image.")
fits.close()
os.chdir("../working")
......
......@@ -78,7 +78,7 @@ class CapabilityInfo(CapabilityInfoIF):
:param name: Name of capability to edit
:param steps: New capability sequence or None if wanting to leave unchanged
:param max_jobs: New number of max jobs or None if wanting to leave unchanged
:param enabled: New enabled state or None is wanting to leave unchanges
:param enabled: New enabled state or None if wanting to leave unchanged
:return: True if the capability was successfully edited, else False
"""
changes = {}
......@@ -138,6 +138,7 @@ class CapabilityInfo(CapabilityInfoIF):
:return: new CapabilityVersion
"""
request = self.lookup_capability_request(capability_request_id)
logger.info(f"Parent Request: {request.__json__()}")
current_version_files = request.current_version.files
version = CapabilityVersion(
capability_request_id=capability_request_id,
......@@ -146,6 +147,7 @@ class CapabilityInfo(CapabilityInfoIF):
request=request,
)
self.save_entity(version)
logger.info(f"New Version: {version.__json__()}")
# Reset request state to Created
request.state = CapabilityRequestState.Created.name
......@@ -338,6 +340,7 @@ class CapabilityInfo(CapabilityInfoIF):
:return:
"""
logger.info(f"FILES: {previous_version_files}")
for file in previous_version_files:
self.save_version_file(version=version, filename=file.filename, content=file.content)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment