Skip to content

Commit

Permalink
Removed pantry_basename from Input. refs: #42
Browse files Browse the repository at this point in the history
  • Loading branch information
spanezz committed Dec 6, 2021
1 parent 401212e commit ee09132
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
7 changes: 0 additions & 7 deletions arkimapslib/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,6 @@ def __init__(self, name: str, defined_in: str, model: Optional[str] = None, mgri
self.defined_in = defined_in
# Extra arguments passed to mgrib on loading
self.mgrib = mgrib
# Basename of files for this input in the pantry
# This has no path, and no +step.ext suffix
if self.model is None:
self.pantry_basename = self.name
else:
self.pantry_basename = f"{self.model}_{self.name}"

@classmethod
def create(cls, type: str = "default", **kw):
Expand Down Expand Up @@ -125,7 +119,6 @@ def to_dict(self):
"model": self.model,
"defined_in": self.defined_in,
"mgrib": self.mgrib,
"pantry_basename": self.pantry_basename,
}

def get_all_inputs(self) -> List[str]:
Expand Down
24 changes: 20 additions & 4 deletions arkimapslib/pantry.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ def get_basename(self, inp: "inputs.Input", instant: "inputs.Instant", fmt="grib
Return the relative name within the pantry of the file corresponding to
the given input and instant
"""
return inp.pantry_basename + f"{instant.pantry_suffix()}.{fmt}"
if inp.model is None:
pantry_basename = inp.name
else:
pantry_basename = f"{inp.model}_{inp.name}"
return pantry_basename + f"{instant.pantry_suffix()}.{fmt}"

def get_fullname(self, inp: "inputs.Input", instant: "inputs.Instant", fmt="grib") -> str:
"""
Expand All @@ -123,7 +127,11 @@ def get_accessory_fullname(self, inp: "inputs.Input", suffix: str) -> str:
Return the relative name within the pantry of the file corresponding to
the given input and instant
"""
return os.path.join(self.data_root, f"{inp.pantry_basename}-{suffix}")
if inp.model is None:
pantry_basename = inp.name
else:
pantry_basename = f"{inp.model}_{inp.name}"
return os.path.join(self.data_root, f"{pantry_basename}-{suffix}")

def get_input_file(self, inp: "inputs.Input", instant: "inputs.Instant", fmt="grib") -> "inputs.InputFile":
"""
Expand All @@ -132,7 +140,11 @@ def get_input_file(self, inp: "inputs.Input", instant: "inputs.Instant", fmt="gr
return inputs.InputFile(self.get_fullname(inp, instant, fmt=fmt), inp, instant)

def get_eccodes_fullname(self, inp: "inputs.Input", fmt="grib") -> str:
return f"{self.data_root}/{inp.pantry_basename}_[year]_[month]_[day]_[hour]_[minute]_[second]+[endStep].{fmt}"
if inp.model is None:
pantry_basename = inp.name
else:
pantry_basename = f"{inp.model}_{inp.name}"
return f"{self.data_root}/{pantry_basename}_[year]_[month]_[day]_[hour]_[minute]_[second]+[endStep].{fmt}"

def get_instants(self, input_name: str) -> Dict[Optional[inputs.Instant], "inputs.InputFile"]:
"""
Expand Down Expand Up @@ -264,7 +276,11 @@ def dispatch(self, md: arkimet.Metadata) -> bool:

reftime = md.to_python("reftime")["time"]
source = md.to_python("source")
relname = inp.pantry_basename + (
if inp.model is None:
pantry_basename = inp.name
else:
pantry_basename = f"{inp.model}_{inp.name}"
relname = pantry_basename + (
f"_{reftime.year}_{reftime.month}_{reftime.day}"
f"_{reftime.hour}_{reftime.minute}_{reftime.second}"
f"+{output_step}.{source['format']}")
Expand Down

0 comments on commit ee09132

Please sign in to comment.