-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fixed the streaming bug * rewrite the key from test to validation to be consistent with dataset names
- Loading branch information
Showing
3 changed files
with
80 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
tests/integration_tests/runners/hf_cehrbert_pretrain_runner_streaming_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import os | ||
import shutil | ||
import sys | ||
import tempfile | ||
import unittest | ||
from pathlib import Path | ||
|
||
from datasets import disable_caching | ||
|
||
from cehrbert.runners.hf_cehrbert_pretrain_runner import main | ||
|
||
disable_caching() | ||
os.environ["CUDA_VISIBLE_DEVICES"] = "-1" | ||
os.environ["WANDB_MODE"] = "disabled" | ||
os.environ["TRANSFORMERS_VERBOSITY"] = "info" | ||
|
||
|
||
class HfCehrBertRunnerIntegrationTest(unittest.TestCase): | ||
def setUp(self): | ||
# Get the root folder of the project | ||
root_folder = Path(os.path.abspath(__file__)).parent.parent.parent.parent | ||
data_folder = os.path.join(root_folder, "sample_data", "pretrain") | ||
# Create a temporary directory to store model and tokenizer | ||
self.temp_dir = tempfile.mkdtemp() | ||
self.model_folder_path = os.path.join(self.temp_dir, "model") | ||
Path(self.model_folder_path).mkdir(parents=True, exist_ok=True) | ||
self.dataset_prepared_path = os.path.join(self.temp_dir, "dataset_prepared_path") | ||
Path(self.dataset_prepared_path).mkdir(parents=True, exist_ok=True) | ||
sys.argv = [ | ||
"hf_cehrbert_pretraining_runner.py", | ||
"--model_name_or_path", | ||
self.model_folder_path, | ||
"--tokenizer_name_or_path", | ||
self.model_folder_path, | ||
"--output_dir", | ||
self.model_folder_path, | ||
"--data_folder", | ||
data_folder, | ||
"--dataset_prepared_path", | ||
self.dataset_prepared_path, | ||
"--max_steps", | ||
"10", | ||
"--streaming", | ||
] | ||
|
||
def tearDown(self): | ||
# Remove the temporary directory | ||
shutil.rmtree(self.temp_dir) | ||
|
||
def test_train_model(self): | ||
main() | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |