From 25ef6bcd2695fbdba2b220f618249660276d1d9d Mon Sep 17 00:00:00 2001 From: JingyaHuang Date: Tue, 15 Aug 2023 23:38:05 +0000 Subject: [PATCH] fix inf1 and decoder again --- optimum/neuron/modeling_decoder.py | 24 ++++++++++++++++++++++++ tests/inference/test_modeling_decoder.py | 1 + 2 files changed, 25 insertions(+) diff --git a/optimum/neuron/modeling_decoder.py b/optimum/neuron/modeling_decoder.py index 800570c1e..e214be92a 100644 --- a/optimum/neuron/modeling_decoder.py +++ b/optimum/neuron/modeling_decoder.py @@ -272,3 +272,27 @@ def push_to_hub( path_or_fileobj=os.path.join(os.getcwd(), local_file_path), path_in_repo=hub_file_path, ) + + def git_config_username_and_email(self, git_user: str = None, git_email: str = None): + """ + Sets git user name and email (only in the current repo) + """ + try: + if git_user is not None: + subprocess.run( + ["git", "config", "--system", "user.name", git_user], + stderr=subprocess.PIPE, + stdout=subprocess.PIPE, + check=True, + encoding="utf-8", + ) + if git_email is not None: + subprocess.run( + ["git", "config", "--system", "user.email", git_email], + stderr=subprocess.PIPE, + stdout=subprocess.PIPE, + check=True, + encoding="utf-8", + ) + except subprocess.CalledProcessError as exc: + raise EnvironmentError(exc.stderr) diff --git a/tests/inference/test_modeling_decoder.py b/tests/inference/test_modeling_decoder.py index c6b7df63e..79ece3346 100644 --- a/tests/inference/test_modeling_decoder.py +++ b/tests/inference/test_modeling_decoder.py @@ -41,6 +41,7 @@ def export_model_id(request): @pytest.fixture(scope="module") +@requires_neuronx def neuron_model_path(export_model_id): # For now we need to use a batch_size of 2 because it fails with batch_size == 1 model = NeuronModelForCausalLM.from_pretrained(export_model_id, export=True, batch_size=2)