Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conda create raises TqdmWarning: clamping frac to range [0, 1] warning #14082

Open
2 tasks done
user202729 opened this issue Jul 26, 2024 · 4 comments
Open
2 tasks done
Labels
pending::feedback indicates we are waiting on feedback from the user source::community catch-all for issues filed by community members type::bug describes erroneous operation, use severity::* to classify the type

Comments

@user202729
Copy link

Checklist

  • I added a descriptive title
  • I searched open reports and couldn't find a duplicate

What happened?

As in the title.

Expected value is no warning.

(side note, tqdm/tqdm#1118 suggests maybe the cause is floating point rounding error?)

Conda Info

active environment : None
            shell level : 0
       user config file : /home/username/.condarc
 populated config files : /home/username/.condarc
          conda version : 24.3.0
    conda-build version : not installed
         python version : 3.12.2.final.0
                 solver : libmamba (default)
       virtual packages : __archspec=1=sapphirerapids
                          __conda=24.3.0=0
                          __cuda=12.4=0
                          __glibc=2.35=0
                          __linux=6.5.0=0
                          __unix=0=0
       base environment : /home/username/conda  (writable)
      conda av data dir : /home/username/conda/etc/conda
  conda av metadata url : None
           channel URLs : <redacted>
          package cache : /home/username/conda/pkgs
                          /home/username/.conda/pkgs
       envs directories : /home/username/conda/envs
                          /home/username/.conda/envs
               platform : linux-64
             user-agent : conda/24.3.0 requests/2.31.0 CPython/3.12.2 Linux/6.5.0-1025-oem ubuntu/22.04.4 glibc/2.35 solver/libmamba conda-libmamba-solver/24.1.0 libmambapy/1.5.8 aau/0.4.4 c/. s/. e/.
                UID:GID : 43400:43400
             netrc file : /home/username/.netrc
           offline mode : False

Conda Config

No response

Conda list

No response

Additional Context

No response

@user202729 user202729 added the type::bug describes erroneous operation, use severity::* to classify the type label Jul 26, 2024
@travishathaway travishathaway added the source::community catch-all for issues filed by community members label Jul 26, 2024
@travishathaway
Copy link
Contributor

@user202729,

Can you please share the full error message and tell us the exact command you ran when you encountered this?

@travishathaway travishathaway added the pending::feedback indicates we are waiting on feedback from the user label Jul 26, 2024
@user202729
Copy link
Author

The command:

conda create --name bug --file conda/conda-spec.txt

The full error message is just in the title, it is being produced by

            warn("clamping frac to range [0, 1]", TqdmWarning, stacklevel=2)

in tqdm's std.py.

https://github.com/tqdm/tqdm/blob/master/tqdm/std.py#L155

The warning is printed while the installation screen runs, and it's easy to miss it because the installation screen will overwrite it quickly.

The installation screen looks somewhat like the following (multiple similar lines)

_libgcc_mutex-0.1    | ##################################################################### | 100%

That said, I modified the source code to print out the stack at that, and get the following

  File "/home/user/conda/lib/python3.12/threading.py", line 1030, in _bootstrap
    self._bootstrap_inner()
  File "/home/user/conda/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "/home/user/conda/lib/python3.12/threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "/home/user/conda/lib/python3.12/concurrent/futures/thread.py", line 92, in _worker
    work_item.run()
  File "/home/user/conda/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/user/conda/lib/python3.12/site-packages/conda/core/package_cache_data.py", line 944, in do_cache_action
    cache_action.execute(progress_update_cache_action)
  File "/home/user/conda/lib/python3.12/site-packages/conda/core/path_actions.py", line 1259, in execute
    self._execute_channel(target_package_cache, progress_update_callback)
  File "/home/user/conda/lib/python3.12/site-packages/conda/core/path_actions.py", line 1325, in _execute_channel
    download(
  File "/home/user/conda/lib/python3.12/site-packages/conda/common/io.py", line 85, in decorated
    return f(*args, **kwds)
  File "/home/user/conda/lib/python3.12/site-packages/conda/gateways/connection/download.py", line 66, in download
    download_inner(
  File "/home/user/conda/lib/python3.12/site-packages/conda/gateways/connection/download.py", line 135, in download_inner
    progress_update_callback(
  File "/home/user/conda/lib/python3.12/site-packages/conda/core/package_cache_data.py", line 938, in progress_update_cache_action
    progress_bar.update_to(pct_completed * download_total)
  File "/home/user/conda/lib/python3.12/site-packages/conda/common/io.py", line 505, in update_to
    self.pbar.update(fraction - self.pbar.n)
  File "/home/user/conda/lib/python3.12/site-packages/tqdm/std.py", line 1244, in update
    self.refresh(lock_args=self.lock_args)
  File "/home/user/conda/lib/python3.12/site-packages/tqdm/std.py", line 1349, in refresh
    self.display()
  File "/home/user/conda/lib/python3.12/site-packages/tqdm/std.py", line 1497, in display
    self.sp(self.__str__() if msg is None else msg)
  File "/home/user/conda/lib/python3.12/site-packages/tqdm/std.py", line 1153, in __str__
    return self.format_meter(**self.format_dict)
  File "/home/user/conda/lib/python3.12/site-packages/tqdm/std.py", line 529, in format_meter
    full_bar = Bar(frac,
  File "/home/user/conda/lib/python3.12/site-packages/tqdm/std.py", line 158, in __init__
    traceback.print_stack()

@conda-bot conda-bot added pending::support indicates user is waiting on support from triage engineers and removed pending::feedback indicates we are waiting on feedback from the user labels Jul 26, 2024
@travishathaway
Copy link
Contributor

travishathaway commented Jul 26, 2024

@user202729,

Thanks for giving us more information. I'm actually working on refactoring this part of conda right now, and I am curious how you were able to see that warning. I have never seen that warning on my computer.

If I can recreate this, I would be happy to fix it. Even if I am unable to recreate it myself, it looks like we could at least add a quick check before calling update to make sure we are not passing anything over 100.

@travishathaway travishathaway added pending::feedback indicates we are waiting on feedback from the user and removed pending::support indicates user is waiting on support from triage engineers labels Jul 26, 2024
@user202729
Copy link
Author

From the traceback I can't see anything suspicious either.

            if total_content_length and 0 <= streamed_bytes <= content_length:
                if progress_update_callback:
                    progress_update_callback(
                        (stat_result.st_size   streamed_bytes) / total_content_length
                    )

This is the first step that introduces floating point.

                    self.pbar.update(fraction - self.pbar.n)

Then inside tqdm source code:

        if n < 0:
            self.last_print_n  = n  # for auto-refresh logic to work
        self.n  = nfrac = n / total
            percentage = frac * 100full_bar = Bar(frac,
                           max(1, ncols - disp_len(nobar)) if ncols else 10,
                           charset=Bar.ASCII if ascii is True else ascii or Bar.UTF,
                           colour=colour)
→
        if not 0 <= frac <= 1:
            warn("clamping frac to range [0, 1]", TqdmWarning, stacklevel=2)
            frac = max(0, min(1, frac))

I think floating point error should at least guarantee if b ≤ 1 and 0 ≤ a ≤ 1 then a (b - a) ≤ 1… right?


I guess I can try to attach pdb and debug it a bit in a few days.

@conda-bot conda-bot added pending::support indicates user is waiting on support from triage engineers and removed pending::feedback indicates we are waiting on feedback from the user labels Jul 27, 2024
@travishathaway travishathaway added pending::feedback indicates we are waiting on feedback from the user and removed pending::support indicates user is waiting on support from triage engineers labels Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending::feedback indicates we are waiting on feedback from the user source::community catch-all for issues filed by community members type::bug describes erroneous operation, use severity::* to classify the type
Projects
Status: 🆕 New
Development

No branches or pull requests

3 participants