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

cached_path disappeared from the API #21678

Closed
2 of 4 tasks
johann-petrak opened this issue Feb 17, 2023 · 2 comments
Closed
2 of 4 tasks

cached_path disappeared from the API #21678

johann-petrak opened this issue Feb 17, 2023 · 2 comments

Comments

@johann-petrak
Copy link

johann-petrak commented Feb 17, 2023

System Info

  • transformers version: 4.26.1
  • Platform: Linux-5.15.0-60-generic-x86_64-with-glibc2.17
  • Python version: 3.8.16
  • Huggingface_hub version: 0.12.1
  • PyTorch version (GPU?): 1.13.1+cu117 (True)

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

A tool using an older version of transformers uses

from transformers.file_utils import cached_path

However, this api function disappeared sometime in 2022 but I could not find any information about what it should get replaced with or similar, change log or similar.

However even in the current transformers repo, this method gets used in some example files, sometimes re-defining this method, sometimes using the same import which does not work any longer:

examples/research_projects/visual_bert/modeling_frcnn.py:from utils import WEIGHTS_NAME, Config, cached_path, hf_bucket_url, is_remote_url, load_checkpoint
examples/research_projects/visual_bert/modeling_frcnn.py:                resolved_archive_file = cached_path(
examples/research_projects/visual_bert/utils.py:            resolved_config_file = cached_path(
examples/research_projects/visual_bert/utils.py:def cached_path(
examples/research_projects/lxmert/modeling_frcnn.py:from utils import WEIGHTS_NAME, Config, cached_path, hf_bucket_url, is_remote_url, load_checkpoint
examples/research_projects/lxmert/modeling_frcnn.py:                resolved_archive_file = cached_path(
examples/research_projects/lxmert/utils.py:            resolved_config_file = cached_path(
examples/research_projects/lxmert/utils.py:def cached_path(
examples/research_projects/pplm/run_pplm.py:from transformers.file_utils import cached_path
examples/research_projects/pplm/run_pplm.py:        resolved_archive_file = cached_path(params["url"])
examples/research_projects/pplm/run_pplm.py:            filepath = cached_path(BAG_OF_WORDS_ARCHIVE_MAP[id_or_path])
examples/research_projects/seq2seq-distillation/_test_bash_script.py:from transformers.file_utils import cached_path
examples/research_projects/seq2seq-distillation/_test_bash_script.py:        data_cached = cached_path(

Expected behavior

The import should be possible for backwards compatibility or documentation explain what to replace it with.

Version 4.21.0 seems the last version where that function could get imported

@sgugger
Copy link
Collaborator

sgugger commented Feb 17, 2023

The cached_path API was a private util for our downloads (note that we consider as private anything that is not in the main init). None of the research projects are actively maintained so they will only work with the version of Transformers corresponding to their creation.

You should use the huggingface_hub library to manage downloads and cache of files on the Hub now. The closest thing we have to cached_path is transformers.utils.hub.cached_file in the current version.

@johann-petrak
Copy link
Author

johann-petrak commented Feb 17, 2023

Thanks, I will see if I can monkey-patch that tool/library accordingly.

KumoLiu added a commit to Project-MONAI/MONAI that referenced this issue Dec 29, 2023
Fixes #7338

### Description

transformers' version is pinned to v4.22 since
#5157.
Updated the version refer to
huggingface/transformers#21678.

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
marksgraham pushed a commit to marksgraham/MONAI that referenced this issue Jan 30, 2024
Fixes Project-MONAI#7338

### Description

transformers' version is pinned to v4.22 since
Project-MONAI#5157.
Updated the version refer to
huggingface/transformers#21678.

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Signed-off-by: Mark Graham <markgraham539@gmail.com>
juampatronics pushed a commit to juampatronics/MONAI that referenced this issue Mar 25, 2024
Fixes Project-MONAI#7338

### Description

transformers' version is pinned to v4.22 since
Project-MONAI#5157.
Updated the version refer to
huggingface/transformers#21678.

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Signed-off-by: Juan Pablo de la Cruz Gutiérrez <juampatronics@gmail.com>
Yu0610 pushed a commit to Yu0610/MONAI that referenced this issue Apr 11, 2024
Fixes Project-MONAI#7338

### Description

transformers' version is pinned to v4.22 since
Project-MONAI#5157.
Updated the version refer to
huggingface/transformers#21678.

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Signed-off-by: Yu0610 <612410030@alum.ccu.edu.tw>
vgrau98 pushed a commit to vgrau98/MONAI that referenced this issue Apr 28, 2024
Fixes Project-MONAI#7338

### Description

transformers' version is pinned to v4.22 since
Project-MONAI#5157.
Updated the version refer to
huggingface/transformers#21678.

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants