MCPcopy Create free account
hub / github.com/OpenBitSys/BitDistiller / Request

Class Request

test/general/lm_eval/base.py:952–982  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

950
951
952class Request:
953 def __init__(self, request_type, args, index=None):
954 if request_type not in REQUEST_RETURN_LENGTHS.keys():
955 raise NotImplementedError(
956 "The request type {} is not implemented!".format(request_type)
957 )
958
959 self.request_type = request_type
960 self.args = args
961 self.index = index
962
963 def __iter__(self):
964 if REQUEST_RETURN_LENGTHS[self.request_type] is None:
965 raise IndexError("This request type does not return multiple arguments!")
966 for i in range(REQUEST_RETURN_LENGTHS[self.request_type]):
967 yield Request(self.request_type, self.args, i)
968
969 def __getitem__(self, i):
970 if REQUEST_RETURN_LENGTHS[self.request_type] is None:
971 raise IndexError("This request type does not return multiple arguments!")
972 return Request(self.request_type, self.args, i)
973
974 def __eq__(self, other):
975 return (
976 self.request_type == other.request_type
977 and self.args == other.args
978 and self.index == other.index
979 )
980
981 def __repr__(self):
982 return f"Req_{self.request_type}{self.args}[{self.index}]\n"
983
984
985class RequestFactory:

Callers 3

__iter__Method · 0.85
__getitem__Method · 0.85
fnMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected