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

Move test model folders #17034

Merged
merged 33 commits into from
May 3, 2022
Merged

Move test model folders #17034

merged 33 commits into from
May 3, 2022

Conversation

ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented May 2, 2022

What does this PR do?

As discussed offline, this PR moves model specific test folders (e.g. tests/bert) to tests/models (e.g. tests/models/bert)

In addition to the necessary changes on import, the following changes are made:

  • In some test files regarding processors (tokenizer/feature extractor, etc.), change
SAMPLE_ROBERTA_CONFIG = os.path.join(os.path.dirname(os.path.abspath(__file__)), ".../fixtures/dummy-config.json")

to

SAMPLE_ROBERTA_CONFIG = get_tests_dir("fixtures/dummy-config.json")

(see the commit)

  • The changes (to be reviewed particularly)

    • .circleci/config.yml

    • .github/workflows/self-scheduled.yml

    • src/transformers/commands/add_new_model.py

    • src/transformers/commands/add_new_model_like.py

    • utils/check_repo.py

    • utils/notification_service.py

    • utils/test_fetcher.py

Remarks:

  • The self-push result is here
    • The slack report job has Artifact was not found, job was probably canceled., but this issue exists for some time. My plan is to continue the task of changing self-push report format (and fix this issue)
    • The run_tests_flax_gpu failure is just the same as in other runs. This is not in the scope of this PR.
  • The scheduled CI (partial) result is here. The report is available on Slack.
    • On the GitHub Actions page, the jobs have name like Model tests (models/albert, single-gpu-docker). It becomes a bit long (with models/).
    • Same for the Slack report
      0 |         0 |         3 |         0 |         0 | models_auto
      
    • So far I only ran a subset of models. From the results, I think the PR is ready. We can run a full suite of tests before merge.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented May 2, 2022

The documentation is not available anymore as the PR was closed or merged.

@ydshieh ydshieh requested review from LysandreJik, sgugger and stas00 May 2, 2022 10:13
Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impressive work! My only concern is on the changes in self.scheduled.yml, so I'd really like to launch that CI once and check everything is okay before we merge this.

@ydshieh ydshieh force-pushed the move_test_model_folders branch from e4efa64 to 1080be1 Compare May 2, 2022 15:38
Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very impressive PR, thanks @ydshieh!

If you're rebasing on main to take care of the conflicts, I would advocate to squash all of your commits in a single one, which means you'll only take care of the conflicts once (similarly to a merge). Having 32 commits to rebase on main must be hard :)

Copy link
Contributor

@stas00 stas00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super awesome work, @ydshieh! Thank you!

I made a few minor optional suggestions if these resonate with you. But please feel free to ignore.

I wonder if this

for up in [1, 2, 3]:
tmp_dir = path.parents[up]
if (tmp_dir / "src").is_dir() and (tmp_dir / "tests").is_dir():
break

needs to have another level, or perhaps it's still reaching to the repo's root. I think I coded it originally to have some spare levels.

rm -rf reports
- id: set-matrix
name: Identify models to test
working-directory: /transformers/tests
run: |
echo "::set-output name=matrix::$(python3 -c 'import os; x = list(filter(os.path.isdir, os.listdir(os.getcwd()))); x.sort(); print(x)')"
echo "::set-output name=matrix::$(python3 -c 'import os; tests = os.getcwd(); model_tests = os.listdir(os.path.join(tests, "models")); d1 = sorted(list(filter(os.path.isdir, os.listdir(tests)))); d2 = sorted(list(filter(os.path.isdir, [f"models/{x}" for x in model_tests]))); d1.remove("models"); d = d2 + d1; print(d)')"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a bit difficult to read, may I propose a simplified version which I hope is easier to follow, plus it adds some new lines and additionally removes __pycache__ dir which shouldn't be in the results.

Suggested change
echo "::set-output name=matrix::$(python3 -c 'import os; tests = os.getcwd(); model_tests = os.listdir(os.path.join(tests, "models")); d1 = sorted(list(filter(os.path.isdir, os.listdir(tests)))); d2 = sorted(list(filter(os.path.isdir, [f"models/{x}" for x in model_tests]))); d1.remove("models"); d = d2 + d1; print(d)')"
echo "::set-output name=matrix::$(python3 -c '\
import os; \
tests = os.getcwd(); \
d = set(filter(os.path.isdir, os.listdir(tests) + [f"models/{x}" for x in os.listdir(f"{tests}/models")])); \
d -= set(["models", "__pycache__"]); \
print(sorted(d))')"

Here is just the python snippet:

python -c '\
import os; \
tests = os.getcwd(); \
d = set(filter(os.path.isdir, os.listdir(tests) + [f"models/{x}" for x in os.listdir(f"{tests}/models")])); \
d -= set(["models", "__pycache__"]); \
print(sorted(d))'

which I tested with, I hope I plugged it in correctly above - i.e. untested.



sys.path.append(str(Path(__file__).parent.parent.parent / "utils"))
sys.path.append(str(Path(__file__).parent.parent.parent.parent / "utils"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the number of parent calls is becoming too long, one could do:

Suggested change
sys.path.append(str(Path(__file__).parent.parent.parent.parent / "utils"))
sys.path.append(str(Path(__file__).parents[4] / "utils"))

but it's totally ok like it is right now.

@ydshieh
Copy link
Collaborator Author

ydshieh commented May 3, 2022

Hi, @stas00 Thank you for the feedbacks.

  • Regarding difficult to read (the long command): totally agreed! I had the same feeling, and thought might be a good idea to create a tiny python script and just call it. Otherwise, we can use what you proposed above (after some tests).
  • About parents[4]: thank you for the information!
  • I can check TestCasePlus later.

I would prefer to merge as it is now, and work on these points in another PR. The main reason is that I ran the full suite of tests, the results look all good, and would like to merge with a version that has been fully tested :-)

@ydshieh ydshieh force-pushed the move_test_model_folders branch from 1080be1 to 9bc8e1a Compare May 3, 2022 09:47
@ydshieh
Copy link
Collaborator Author

ydshieh commented May 3, 2022

Merged now (after rebase on main for the merged flax_bert and yolos PRs).

@ydshieh ydshieh merged commit 19420fd into main May 3, 2022
@ydshieh ydshieh deleted the move_test_model_folders branch May 3, 2022 12:42
nandwalritik pushed a commit to nandwalritik/transformers that referenced this pull request May 3, 2022
* move test model folders (TODO: fix imports and others)

* fix (potentially partially) imports (in model test modules)

* fix (potentially partially) imports (in tokenization test modules)

* fix (potentially partially) imports (in feature extraction test modules)

* fix import utils.test_modeling_tf_core

* fix path ../fixtures/

* fix imports about generation.test_generation_flax_utils

* fix more imports

* fix fixture path

* fix get_test_dir

* update module_to_test_file

* fix get_tests_dir from wrong transformers.utils

* update config.yml (CircleCI)

* fix style

* remove missing imports

* update new model script

* update check_repo

* update SPECIAL_MODULE_TO_TEST_MAP

* fix style

* add __init__

* update self-scheduled

* fix add_new_model scripts

* check one way to get location back

* python setup.py build install

* fix import in test auto

* update self-scheduled.yml

* update slack notification script

* Add comments about artifact names

* fix for yolos

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
stevhliu pushed a commit to stevhliu/transformers that referenced this pull request May 3, 2022
* move test model folders (TODO: fix imports and others)

* fix (potentially partially) imports (in model test modules)

* fix (potentially partially) imports (in tokenization test modules)

* fix (potentially partially) imports (in feature extraction test modules)

* fix import utils.test_modeling_tf_core

* fix path ../fixtures/

* fix imports about generation.test_generation_flax_utils

* fix more imports

* fix fixture path

* fix get_test_dir

* update module_to_test_file

* fix get_tests_dir from wrong transformers.utils

* update config.yml (CircleCI)

* fix style

* remove missing imports

* update new model script

* update check_repo

* update SPECIAL_MODULE_TO_TEST_MAP

* fix style

* add __init__

* update self-scheduled

* fix add_new_model scripts

* check one way to get location back

* python setup.py build install

* fix import in test auto

* update self-scheduled.yml

* update slack notification script

* Add comments about artifact names

* fix for yolos

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
nandwalritik pushed a commit to nandwalritik/transformers that referenced this pull request May 4, 2022
* move test model folders (TODO: fix imports and others)

* fix (potentially partially) imports (in model test modules)

* fix (potentially partially) imports (in tokenization test modules)

* fix (potentially partially) imports (in feature extraction test modules)

* fix import utils.test_modeling_tf_core

* fix path ../fixtures/

* fix imports about generation.test_generation_flax_utils

* fix more imports

* fix fixture path

* fix get_test_dir

* update module_to_test_file

* fix get_tests_dir from wrong transformers.utils

* update config.yml (CircleCI)

* fix style

* remove missing imports

* update new model script

* update check_repo

* update SPECIAL_MODULE_TO_TEST_MAP

* fix style

* add __init__

* update self-scheduled

* fix add_new_model scripts

* check one way to get location back

* python setup.py build install

* fix import in test auto

* update self-scheduled.yml

* update slack notification script

* Add comments about artifact names

* fix for yolos

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
elusenji pushed a commit to elusenji/transformers that referenced this pull request Jun 12, 2022
* move test model folders (TODO: fix imports and others)

* fix (potentially partially) imports (in model test modules)

* fix (potentially partially) imports (in tokenization test modules)

* fix (potentially partially) imports (in feature extraction test modules)

* fix import utils.test_modeling_tf_core

* fix path ../fixtures/

* fix imports about generation.test_generation_flax_utils

* fix more imports

* fix fixture path

* fix get_test_dir

* update module_to_test_file

* fix get_tests_dir from wrong transformers.utils

* update config.yml (CircleCI)

* fix style

* remove missing imports

* update new model script

* update check_repo

* update SPECIAL_MODULE_TO_TEST_MAP

* fix style

* add __init__

* update self-scheduled

* fix add_new_model scripts

* check one way to get location back

* python setup.py build install

* fix import in test auto

* update self-scheduled.yml

* update slack notification script

* Add comments about artifact names

* fix for yolos

Co-authored-by: ydshieh <ydshieh@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

Successfully merging this pull request may close these issues.

5 participants