Skip to content

Commit

Permalink
Merge branch 'main' into 771-pass-through-resolve_path-when-not-acces…
Browse files Browse the repository at this point in the history
…sible
  • Loading branch information
dagewa authored Dec 2, 2024
2 parents 533e5c4 + edb60e4 commit c129212
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions newsfragments/768.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
``dials.import``: add a progress bar for the import process, particularly
useful when importing thousands of files
1 change: 1 addition & 0 deletions newsfragments/773.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``dials.import``: force tqdm output to stdout not stderr as default
1 change: 1 addition & 0 deletions newsfragments/774.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``dials.show``: hide tqdm if DIALS_NOBANNER
1 change: 1 addition & 0 deletions newsfragments/775.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``dials.import``: set tqdm output to stdout (again)
12 changes: 11 additions & 1 deletion src/dxtbx/model/experiment_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from typing import Any, Callable, Generator, Iterable

import natsort
from tqdm import tqdm

import dxtbx
from dxtbx.format.Format import Format
Expand Down Expand Up @@ -664,14 +665,23 @@ def from_filenames(
"""Create a list of data blocks from a list of directory or file names."""
experiments = ExperimentList()

# Cast filenames to a list from whatever iterator they are
filenames = list(filenames)

# Process each file given by this path list
to_process = _openingpathiterator(filenames)
find_format = FormatChecker()

format_groups = collections.defaultdict(list)
if format_kwargs is None:
format_kwargs = {}
for filename in to_process:

if os.isatty and len(filenames) > 1 and "DIALS_NOBANNER" not in os.environ:
filename_iter = tqdm(to_process, total=len(filenames), file=sys.stdout)
else:
filename_iter = to_process

for filename in filename_iter:
# We now have a file, pre-opened by Format.open_file (therefore
# cached). Determine its type, and prepare to put into a group
format_class = find_format.find_format(filename)
Expand Down

0 comments on commit c129212

Please sign in to comment.