-
Notifications
You must be signed in to change notification settings - Fork 38
Refactor: Reorganize run_task and unit tests into dedicated directories #1159
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
base: main
Are you sure you want to change the base?
Conversation
…d correct base_dir resolution in sanitize_marian_args
Hi @gregtatum, just wanted to see if you’ve had a chance to look at this. I'd be willing to make any changes needed. Thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking much nicer! I'm requesting changes for the following:
pathlib
inconsistencies, and theparent[1]
pattern being confusing.- pyproject.toml
exclude
list needs updating for the type suppressions. - Dependency changes need to be reverted
Plus there were a few other smaller things I commented on. This is getting close! Thanks for the work on it.
pipeline/eval/requirements/eval.in
Outdated
@@ -1,2 +1,4 @@ | |||
sacrebleu[ja,ko]==2.4.2 | |||
unbabel-comet==2.2.2 | |||
numpy==1.26.4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think a refactor for file paths should need to change any dependencies here. I know our dependency situation can be brittle across different machines. We pretty much require that everything run in docker, due to things breaking outside of docker.
task docker
will start up docker. If you can try on main
to run that and verify that the tests run locally for you without changing any dependencies. If it's still failing within docker then please file an issue and we'll need to fix that first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So basically these files should be unchanged:
pipeline/eval/requirements/eval.in
pipeline/eval/requirements/eval.txt
pipeline/translate/requirements/translate-ctranslate2.in
pipeline/translate/requirements/translate-ctranslate2.txt
poetry.lock
pyproject.toml <- revert dependency changes, keep other changes
pyproject.toml
Outdated
@@ -57,7 +57,7 @@ hanzidentifier = "1.2.0" | |||
psutil= "6.0.0" | |||
|
|||
[tool.poetry.group.utils-docker.dependencies] | |||
PyICU = "2.8.1" | |||
PyICU = "^2.11" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it looks like someone is updating PyICU again. We'll probably want to update it, but that should be a different PR. You are welcome to open another one with this change, but it's best to keep PRs as small as possible.
pyproject.toml
Outdated
PyICU = "^2.11" | ||
|
||
|
||
[tool.poetry.group.dev.dependencies] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably can be reverted as well.
@@ -120,6 +126,7 @@ build-backend = "poetry.core.masonry.api" | |||
|
|||
[tool.pytest.ini_options] | |||
testpaths = ["tests"] | |||
pythonpath = ["."] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a reasonable change to me.
@@ -120,6 +126,7 @@ build-backend = "poetry.core.masonry.api" | |||
|
|||
[tool.pytest.ini_options] | |||
testpaths = ["tests"] | |||
pythonpath = ["."] | |||
markers = [ | |||
# Run tests outside of docker: | |||
# task test -- -m "not docker_amd64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't comment on the files themselves, but below there are:
tests/data/tests/en-ca-teacher-1.npz
tests/data/tests/en-ca-vocab.spm
I think these don't need to be added to this PR, and should be removed. This should be a refactor so we'll not need more files.
tests/task/test_eval.py
Outdated
|
||
en_fake_translated = "\n".join([line.upper() for line in ru_sample.split("\n")]) | ||
ru_fake_translated = "\n".join([line.upper() for line in en_sample.split("\n")]) | ||
|
||
current_folder = os.path.dirname(os.path.abspath(__file__)) | ||
fixtures_path = os.path.join(current_folder, "fixtures") | ||
root_path = os.path.abspath(os.path.join(current_folder, "..")) | ||
fixtures_path = (Path(__file__).resolve().parents[1] / "fixtures").as_posix() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't mix the pathlib and os.path
utilities here. I would prefer one or the other.
The simplest would be to make this work without pathlib. I generally prefer pathlib, but that does mean changing more lines of code here.
tests/task/test_eval.py
Outdated
@@ -106,12 +107,12 @@ def run_eval_test(params) -> None: | |||
} | |||
|
|||
if comet == "skipped": | |||
env["COMET_SKIP"] = "1" | |||
env["COMET_SKIP"] = "1" # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, the exclude
paths need updating in the pyproject.toml
. Rather than fixing files in a big PR, it's better to split them into smaller PRs.
tests/task/test_training.py
Outdated
|
||
pytestmark = [pytest.mark.docker_amd64] | ||
|
||
current_folder = os.path.dirname(os.path.abspath(__file__)) | ||
fixtures_path = os.path.join(current_folder, "fixtures") | ||
fixtures_path = (Path(__file__).resolve().parents[1] / "fixtures").as_posix() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here with my previous comments on pathlib. I'll stop commenting on this, but if you can look through the rest of the PR for anything else where my feedback would apply.
tests/task/test_training.py
Outdated
@@ -19,15 +20,15 @@ | |||
|
|||
|
|||
def validate_alignments(corpus_path, vocab_src_path, vocab_trg_path): | |||
sp_src = spm.SentencePieceProcessor(model_file=vocab_src_path) | |||
sp_trg = spm.SentencePieceProcessor(model_file=vocab_trg_path) | |||
sp_src = spm.SentencePieceProcessor(model_file=vocab_src_path) # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, I'll stop commenting on the type suppressions, but the exclude list should be fixed instead.
tests/unit/test_tracking_cli.py
Outdated
|
||
|
||
@patch( | ||
"translations_parser.cli.taskcluster.get_args", | ||
return_value=argparse.Namespace( | ||
input_file=Path(__file__).parent / "data" / "taskcluster.log", | ||
input_file=Path(__file__).resolve().parents[1] / "data" / "taskcluster.log", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To expand on my earlier comments around pathlib, I find this style to be really confusing where you are indexing into the array of parents.
I would prefer something simpler like:
Path(__file__).parent / "../data/taskcluster.log"
Hi @gregtatum, I've made the requested corrections and pushed the updates. However, two tests are currently failing: tests/unit/test_tracking_cli.py::test_experiments_marian_1_10 tests/unit/test_tracking_cli.py::test_experiments_marian_1_12 The logs indicate assertion errors, but the exact details of the failures are not fully exposed in the test summary. From the logs, it seems the failure might be linked to how experiments Marian versions 1.10 and 1.12 are parsed, possibly affected by how the changes interact with log parsing or configuration file access in the Taskcluster context. I'm currently investigating this further, but if you can confirm whether this failure is expected due to a known issue with these versions, I’d appreciate your input. Thank you once again. |
This pull request addresses issue #591 by reorganizing the test structure to improve clarity and maintainability.
Changes:
run_task
into a newtests/task/
directory.tests/unit/
directory.task test
to ensure functionality remains unchanged.Closes #591