Skip to content

Commit

Permalink
black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
philipmac committed Mar 20, 2023
1 parent 5ea1a4d commit 4e7e9cd
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
30 changes: 22 additions & 8 deletions em_workflows/brt/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ def list_paired_files(fnames: List[Path]) -> List[Path]:
pairs.append(Path(fname_no_b))
return pairs


@task
def cleanup_files(file_path: FilePath, pattern=str):
f = f"{file_path.working_dir.as_posix()}/{pattern}"
Expand All @@ -331,6 +332,7 @@ def cleanup_files(file_path: FilePath, pattern=str):
os.remove(_file)
print(files_to_rm)


# @task
# def check_inputs_paired(fps: List[Path]):
# """
Expand Down Expand Up @@ -424,10 +426,16 @@ def cleanup_files(file_path: FilePath, pattern=str):
tilt_movie_assets = gen_tilt_movie.map(
file_path=fps, upstream_tasks=[keyimg_assets]
)
cleanup_files.map(file_path=fps, pattern=unmapped("*_align_*.mrc"),
upstream_tasks=[tilt_movie_assets, thumb_assets, keyimg_assets])
cleanup_files.map(file_path=fps, pattern=unmapped("*ali*.jpg"),
upstream_tasks=[tilt_movie_assets, thumb_assets, keyimg_assets])
cleanup_files.map(
file_path=fps,
pattern=unmapped("*_align_*.mrc"),
upstream_tasks=[tilt_movie_assets, thumb_assets, keyimg_assets],
)
cleanup_files.map(
file_path=fps,
pattern=unmapped("*ali*.jpg"),
upstream_tasks=[tilt_movie_assets, thumb_assets, keyimg_assets],
)
# END TILT MOVIE GENERATION

# START RECONSTR MOVIE GENERATION:
Expand All @@ -444,10 +452,16 @@ def cleanup_files(file_path: FilePath, pattern=str):
file_path=fps, upstream_tasks=[averagedVolume_assets]
)
recon_movie_assets = gen_recon_movie.map(file_path=fps, upstream_tasks=[ave_jpgs])
cleanup_files.map(file_path=fps, pattern=unmapped("*_mp4.*.jpg"),
upstream_tasks=[recon_movie_assets, ave_jpgs])
cleanup_files.map(file_path=fps, pattern=unmapped("*_ave*.mrc"),
upstream_tasks=[recon_movie_assets, ave_jpgs])
cleanup_files.map(
file_path=fps,
pattern=unmapped("*_mp4.*.jpg"),
upstream_tasks=[recon_movie_assets, ave_jpgs],
)
cleanup_files.map(
file_path=fps,
pattern=unmapped("*_ave*.mrc"),
upstream_tasks=[recon_movie_assets, ave_jpgs],
)
# # END RECONSTR MOVIE

# Binned volume assets, for volslicer.
Expand Down
11 changes: 5 additions & 6 deletions em_workflows/dm_conversion/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def convert_2d_mrc_to_tiff(file_path: FilePath) -> None:
used the smaller of x and y (4092/1024)
"""
utils.log(f"Checking {file_path} for mrc inputs")
large_dim = 1024 # TODO probably config this
large_dim = 1024 # TODO probably config this
if file_path.fp_in.suffix.lower() == ".mrc":
# nifti_fp = neuroglancer.gen_niftis.__wrapped__(file_path)
# nifti_fp = neuroglancer.gen_niftis.__wrapped__(file_path)
# utils.log(f"+++++++++++++++++++++++++++++++++++++++++++++")
# min_max_histo = neuroglancer.gen_min_max_histo(file_path)
# utils.log(min_max_histo)
Expand Down Expand Up @@ -179,7 +179,6 @@ def scale_jpegs(file_path: FilePath, size: str) -> Optional[dict]:
return asset_elt



# @task
# def list_files(input_dir: Path, exts: List[str], single_file: str = None) -> List[Path]:
# """
Expand Down Expand Up @@ -212,8 +211,6 @@ def scale_jpegs(file_path: FilePath, size: str) -> Optional[dict]:
# return _files




with Flow(
"dm_to_jpeg",
state_handlers=[utils.notify_api_completion, utils.notify_api_running],
Expand Down Expand Up @@ -269,7 +266,9 @@ def scale_jpegs(file_path: FilePath, size: str) -> Optional[dict]:
prim_fp=callback_with_thumbs, asset=keyimg_assets
)
# finally filter error states, and convert to JSON and send.
rm_workdirs = utils.cleanup_workdir.map(fp=fps, upstream_tasks=[callback_with_keyimgs])
rm_workdirs = utils.cleanup_workdir.map(
fp=fps, upstream_tasks=[callback_with_keyimgs]
)
filtered_callback = utils.filter_results(callback_with_keyimgs)

callback_sent = utils.send_callback_body(
Expand Down
8 changes: 5 additions & 3 deletions em_workflows/sem_tomo/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from prefect import Flow, task, Parameter, unmapped
from prefect.run_configs import LocalRun
from em_workflows.config import Config

# from em_workflows.shell_task_echo import ShellTaskEcho
from em_workflows.utils import utils
from em_workflows.utils import neuroglancer as ng
Expand Down Expand Up @@ -261,7 +262,7 @@ def gen_keyimg_small(fp_in: FilePath) -> Dict:
- The corrected mrc file is then contrast adjusted with mean std dev magic numbers "150,40" in gen_newstack_norm_command(), this is referred to as the base mrc
- A movie is created using the base.mrc file.
- the midpoint of that file is computed, and snapshots are created using this midpoint.
- We now want to create the pyramid assets, for neuroglancer / viewer.
- We now want to create the pyramid assets, for neuroglancer / viewer.
- Firstly create nifti file using the base mrc, then convert this to ng format.
- To conclude, send callback stating the location of the various outputs.
"""
Expand Down Expand Up @@ -298,7 +299,6 @@ def gen_keyimg_small(fp_in: FilePath) -> Dict:
fp_in=fps, upstream_tasks=[stretchs, align_mrcs]
)


base_mrcs = gen_newstack_norm_command.map(
fp_in=fps, upstream_tasks=[corrected_mrc_assets]
)
Expand Down Expand Up @@ -338,7 +338,9 @@ def gen_keyimg_small(fp_in: FilePath) -> Dict:
callback_with_corr_movies = utils.add_asset.map(
prim_fp=callback_with_corr_mrcs, asset=corrected_movie_assets
)
rm_workdirs = utils.cleanup_workdir.map(fp=fps, upstream_tasks=[callback_with_corr_movies])
rm_workdirs = utils.cleanup_workdir.map(
fp=fps, upstream_tasks=[callback_with_corr_movies]
)

# finally filter error states, and convert to JSON and send.
filtered_callback = utils.filter_results(callback_with_corr_movies)
Expand Down

0 comments on commit 4e7e9cd

Please sign in to comment.