Skip to content

Commit

Permalink
Make context application conditional on adapter availability
Browse files Browse the repository at this point in the history
  • Loading branch information
calpt committed Feb 2, 2022
1 parent ffc8519 commit 6ed088f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/transformers/adapters/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,14 @@ def wrap(cls, f):

@functools.wraps(f)
def wrapper_func(self, *args, **kwargs):
context = cls(self, *args, **kwargs)
cls.get_contexts().append(context)
results = f(self, *args, **kwargs)
cls.get_contexts().pop()
return results
if self.config.adapters is not None:
context = cls(self, *args, **kwargs)
cls.get_contexts().append(context)
results = f(self, *args, **kwargs)
cls.get_contexts().pop()
return results
else:
return f(self, *args, **kwargs)

return wrapper_func

Expand Down

0 comments on commit 6ed088f

Please sign in to comment.