-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ENH Stream file merging task * ENH Added header to module * ENH Reading parameters for stream merging task from database * ENH Default out_file parameter for stream file merging task * BUG Remove unused options from parameter model * BUG Switched to internal method to print feedback * ENH Renamed task * Fixed bugs in task renaming and
- Loading branch information
Showing
6 changed files
with
132 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
"""Pydantic models for Task parameters and configuration.""" | ||
|
||
from .base import * | ||
from .tests import * | ||
from .smd import * | ||
from .sfx_find_peaks import * | ||
from .sfx_index import * | ||
from .sfx_merge import * | ||
from .sfx_solve import * | ||
from .sfx_find_peaks import * | ||
from .smd import * | ||
from .tests import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
""" | ||
Classes for indexing tasks in SFX. | ||
Classes: | ||
ConcatenateStreamFIles: task that merges multiple stream files into a single file. | ||
""" | ||
|
||
__all__ = ["ConcatenateStreamFiles"] | ||
__author__ = "Valerio Mariani" | ||
|
||
import shutil | ||
import sys | ||
from pathlib import Path | ||
from typing import BinaryIO, List | ||
|
||
import numpy | ||
from mpi4py import MPI | ||
|
||
from lute.execution.ipc import Message | ||
from lute.io.models.base import * | ||
from lute.tasks.task import * | ||
|
||
|
||
class ConcatenateStreamFiles(Task): | ||
""" | ||
Task that merges stream files located within a directory tree. | ||
""" | ||
|
||
def __init__(self, *, params: TaskParameters) -> None: | ||
super().__init__(params=params) | ||
|
||
def _run(self) -> None: | ||
|
||
stream_file_path: Path = Path(self._task_parameters.in_file) | ||
stream_file_list: List[Path] = list( | ||
stream_file_path.rglob(f"{self._task_parameters.tag}_*.stream") | ||
) | ||
|
||
processed_file_list = [str(stream_file) for stream_file in stream_file_list] | ||
|
||
msg: Message = Message( | ||
contents=f"Merging following stream files: {processed_file_list} into " | ||
f"{self._task_parameters.out_file}", | ||
) | ||
self._report_to_executor(msg) | ||
|
||
wfd: BinaryIO | ||
with open(self._task_parameters.out_file, "wb") as wfd: | ||
infile: Path | ||
for infile in stream_file_list: | ||
fd: BinaryIO | ||
with open(infile, "rb") as fd: | ||
shutil.copyfileobj(fd, wfd) |