Skip to content

Commit

Permalink
Added calls to prepare() to ensure requirement checks are done early
Browse files Browse the repository at this point in the history
Signed-off-by: Yoav Katz <katz@il.ibm.com>
  • Loading branch information
yoavkatz committed Sep 25, 2024
1 parent df214bc commit 6338752
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/unitxt/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ class HFSystemFormat(BaseFormat):
_requirements_list = ["transformers"]

def prepare(self):
super().prepare()
from transformers import AutoTokenizer

self.tokenizer = AutoTokenizer.from_pretrained(self.model_name)
Expand Down
3 changes: 3 additions & 0 deletions src/unitxt/image_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def process_instance_value(self, value: Any, instance: Dict[str, Any]):


class ImageFieldOperator(FieldOperator, PillowMixin):
# Required here, because PillowMixin _requirements_list is not inherited
_requirements_list = {"PIL": "pip install pillow"}

@abstractmethod
def process_image(self, image):
pass
Expand Down
1 change: 1 addition & 0 deletions src/unitxt/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def prepare_engine(self):
pass

def prepare(self):
super().prepare()
if not settings.mock_inference_mode:
self.prepare_engine()

Expand Down
2 changes: 1 addition & 1 deletion src/unitxt/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class PackageRequirementsMixin(Artifact):
)

def prepare(self):
super().prepare()
self.check_missing_requirements()
super().prepare()

def check_missing_requirements(self, requirements=None):
if requirements is None:
Expand Down

0 comments on commit 6338752

Please sign in to comment.