id
int64
1
6.07M
name
stringlengths
1
295
code
stringlengths
12
426k
language
stringclasses
1 value
source_file
stringlengths
5
202
start_line
int64
1
158k
end_line
int64
1
158k
repo
dict
7,801
to_snake_case
def to_snake_case(name): s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
python
wandb/vendor/gql-0.2.0/wandb_gql/utils.py
15
17
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,802
to_const
def to_const(string): return re.sub(r'[\W|^]+', '_', string).upper()
python
wandb/vendor/gql-0.2.0/wandb_gql/utils.py
20
21
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,803
gql
def gql(request_string): if isinstance(request_string, str): source = Source(request_string, 'GraphQL request') return parse(source) else: raise Exception('Received incompatible request "{}".'.format(request_string))
python
wandb/vendor/gql-0.2.0/wandb_gql/gql.py
5
10
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,804
__init__
def __init__(self, schema): self.schema = schema
python
wandb/vendor/gql-0.2.0/wandb_gql/transport/local_schema.py
6
7
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,805
execute
def execute(self, document, *args, **kwargs): return execute( self.schema, document, *args, **kwargs )
python
wandb/vendor/gql-0.2.0/wandb_gql/transport/local_schema.py
9
15
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,806
__init__
def __init__(self, url, headers=None, cookies=None): self.url = url self.headers = headers self.cookies = cookies
python
wandb/vendor/gql-0.2.0/wandb_gql/transport/http.py
3
6
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,807
__init__
def __init__(self, url, auth=None, use_json=False, timeout=None, **kwargs): """ :param url: The GraphQL URL :param auth: Auth tuple or callable to enable Basic/Digest/Custom HTTP Auth :param use_json: Send request body as JSON instead of form-urlencoded :param timeout: Specifies ...
python
wandb/vendor/gql-0.2.0/wandb_gql/transport/requests.py
11
21
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,808
execute
def execute(self, document, variable_values=None, timeout=None): query_str = print_ast(document) payload = { 'query': query_str, 'variables': variable_values or {} } data_key = 'json' if self.use_json else 'data' post_args = { 'headers': self....
python
wandb/vendor/gql-0.2.0/wandb_gql/transport/requests.py
23
46
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,809
getCharacter
def getCharacter(id): return humanData.get(id) or droidData.get(id)
python
wandb/vendor/gql-0.2.0/tests/starwars/fixtures.py
77
78
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,810
getFriends
def getFriends(character): return map(getCharacter, character.friends)
python
wandb/vendor/gql-0.2.0/tests/starwars/fixtures.py
81
82
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,811
getHero
def getHero(episode): if episode == 5: return luke return artoo
python
wandb/vendor/gql-0.2.0/tests/starwars/fixtures.py
85
88
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,812
getHuman
def getHuman(id): return humanData.get(id)
python
wandb/vendor/gql-0.2.0/tests/starwars/fixtures.py
91
92
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,813
getDroid
def getDroid(id): return droidData.get(id)
python
wandb/vendor/gql-0.2.0/tests/starwars/fixtures.py
95
96
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,814
pytest_collection_finish
def pytest_collection_finish(session): """Handle the pytest collection finish hook: configure pyannotate. Explicitly delay importing `collect_types` until all tests have been collected. This gives gevent a chance to monkey patch the world before importing pyannotate. """ ...
python
wandb/vendor/promise-2.3.0/conftest.py
12
19
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,815
collect_types_fixture
def collect_types_fixture(): from pyannotate_runtime import collect_types collect_types.resume() yield collect_types.pause()
python
wandb/vendor/promise-2.3.0/conftest.py
22
26
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,816
pytest_sessionfinish
def pytest_sessionfinish(session, exitstatus): from pyannotate_runtime import collect_types collect_types.dump_stats("type_info.json")
python
wandb/vendor/promise-2.3.0/conftest.py
28
30
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,817
get_default_scheduler
def get_default_scheduler(): # type: () -> ImmediateScheduler return default_scheduler
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
46
48
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,818
set_default_scheduler
def set_default_scheduler(scheduler): global default_scheduler default_scheduler = scheduler
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
51
53
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,819
make_self_resolution_error
def make_self_resolution_error(): # type: () -> TypeError return TypeError("Promise is self")
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
78
80
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,820
try_catch
def try_catch(handler, *args, **kwargs): # type: (Callable, Any, Any) -> Union[Tuple[Any, None], Tuple[None, Tuple[Exception, Optional[TracebackType]]]] try: return (handler(*args, **kwargs), None) except Exception as e: tb = exc_info()[2] return (None, (e, tb))
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
83
89
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,821
__init__
def __init__(self, executor=None, scheduler=None): # type: (Optional[Callable[[Callable[[T], None], Callable[[Exception], None]], None]], Any) -> None """ Initialize the Promise into a pending state. """ # self._state = STATE_PENDING # type: int # self._is_final = False ...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
123
149
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,822
scheduler
def scheduler(self): # type: () -> ImmediateScheduler return self._scheduler or default_scheduler
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
152
154
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,823
future
def future(self): # type: (Promise) -> Future if not self._future: self._future = Future() # type: ignore self._then( # type: ignore self._future.set_result, self._future.set_exception ) return self._future
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
157
164
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,824
__iter__
def __iter__(self): # type: () -> Iterator return iterate_promise(self._target()) # type: ignore
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
166
168
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,825
_deprecated_reject
def _deprecated_reject(self, e): self.do_reject(e)
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
177
178
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,826
_deprecated_resolve
def _deprecated_resolve(self, value): self.do_resolve(value)
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
185
186
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,827
_resolve_callback
def _resolve_callback(self, value): # type: (T) -> None if value is self: return self._reject_callback(make_self_resolution_error(), False) if not self.is_thenable(value): return self._fulfill(value) promise = self._try_convert_to_promise(value)._target() ...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
188
214
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,828
_settled_value
def _settled_value(self, _raise=False): # type: (bool) -> Any assert not self._is_following if self._state == STATE_FULFILLED: return self._rejection_handler0 elif self._state == STATE_REJECTED: if _raise: raise_val = self._fulfillment_handler0 ...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
216
226
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,829
_fulfill
def _fulfill(self, value): # type: (T) -> None if value is self: err = make_self_resolution_error() # self._attach_extratrace(err) return self._reject(err) self._state = STATE_FULFILLED self._rejection_handler0 = value if self._length > 0: ...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
228
241
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,830
_reject
def _reject(self, reason, traceback=None): # type: (Exception, Optional[TracebackType]) -> None self._state = STATE_REJECTED self._fulfillment_handler0 = reason self._traceback = traceback if self._is_final: assert self._length == 0 async_instance.fatal_e...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
243
262
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,831
_ensure_possible_rejection_handled
def _ensure_possible_rejection_handled(self): # type: () -> None # self._rejection_is_unhandled = True # async_instance.invoke_later(self._notify_unhandled_rejection, self) pass
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
264
268
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,832
_reject_callback
def _reject_callback(self, reason, synchronous=False, traceback=None): # type: (Exception, bool, Optional[TracebackType]) -> None assert isinstance( reason, Exception ), "A promise was rejected with a non-error: {}".format(reason) # trace = ensure_error_object(reason) ...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
270
278
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,833
_clear_callback_data_index_at
def _clear_callback_data_index_at(self, index): # type: (int) -> None assert not self._is_following assert index > 0 base = index * CALLBACK_SIZE - CALLBACK_SIZE self._handlers[base + CALLBACK_PROMISE_OFFSET] = None self._handlers[base + CALLBACK_FULFILL_OFFSET] = None ...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
280
287
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,834
_fulfill_promises
def _fulfill_promises(self, length, value): # type: (int, T) -> None for i in range(1, length): handler = self._fulfillment_handler_at(i) promise = self._promise_at(i) self._clear_callback_data_index_at(i) self._settle_promise(promise, handler, value, None...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
289
295
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,835
_reject_promises
def _reject_promises(self, length, reason): # type: (int, Exception) -> None for i in range(1, length): handler = self._rejection_handler_at(i) promise = self._promise_at(i) self._clear_callback_data_index_at(i) self._settle_promise(promise, handler, reaso...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
297
303
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,836
_settle_promise
def _settle_promise( self, promise, # type: Optional[Promise] handler, # type: Optional[Callable] value, # type: Union[T, Exception] traceback, # type: Optional[TracebackType] ): # type: (...) -> None assert not self._is_following is_promise = isin...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
305
331
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,837
_settle_promise0
def _settle_promise0( self, handler, # type: Optional[Callable] value, # type: Any traceback, # type: Optional[TracebackType] ): # type: (...) -> None promise = self._promise0 self._promise0 = None self._settle_promise(promise, handler, value, trace...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
333
342
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,838
_settle_promise_from_handler
def _settle_promise_from_handler(self, handler, value, promise): # type: (Callable, Any, Promise) -> None value, error_with_tb = try_catch(handler, value) # , promise if error_with_tb: error, tb = error_with_tb promise._reject_callback(error, False, tb) else: ...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
344
352
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,839
_promise_at
def _promise_at(self, index): # type: (int) -> Optional[Promise] assert index > 0 assert not self._is_following return self._handlers.get( # type: ignore index * CALLBACK_SIZE - CALLBACK_SIZE + CALLBACK_PROMISE_OFFSET )
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
354
360
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,840
_fulfillment_handler_at
def _fulfillment_handler_at(self, index): # type: (int) -> Optional[Callable] assert not self._is_following assert index > 0 return self._handlers.get( # type: ignore index * CALLBACK_SIZE - CALLBACK_SIZE + CALLBACK_FULFILL_OFFSET )
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
362
368
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,841
_rejection_handler_at
def _rejection_handler_at(self, index): # type: (int) -> Optional[Callable] assert not self._is_following assert index > 0 return self._handlers.get( # type: ignore index * CALLBACK_SIZE - CALLBACK_SIZE + CALLBACK_REJECT_OFFSET )
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
370
376
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,842
_migrate_callback0
def _migrate_callback0(self, follower): # type: (Promise) -> None self._add_callbacks( follower._fulfillment_handler0, follower._rejection_handler0, follower._promise0, )
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
378
384
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,843
_migrate_callback_at
def _migrate_callback_at(self, follower, index): self._add_callbacks( follower._fulfillment_handler_at(index), follower._rejection_handler_at(index), follower._promise_at(index), )
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
386
391
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,844
_add_callbacks
def _add_callbacks( self, fulfill, # type: Optional[Callable] reject, # type: Optional[Callable] promise, # type: Optional[Promise] ): # type: (...) -> int assert not self._is_following if self._handlers is None: self._handlers = {} in...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
393
435
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,845
_target
def _target(self): # type: () -> Promise ret = self while ret._is_following: ret = ret._followee() return ret
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
437
442
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,846
_followee
def _followee(self): # type: () -> Promise assert self._is_following assert isinstance(self._rejection_handler0, Promise) return self._rejection_handler0
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
444
448
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,847
_set_followee
def _set_followee(self, promise): # type: (Promise) -> None assert self._is_following assert not isinstance(self._rejection_handler0, Promise) self._rejection_handler0 = promise
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
450
454
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,848
_settle_promises
def _settle_promises(self): # type: () -> None length = self._length if length > 0: if self._state == STATE_REJECTED: reason = self._fulfillment_handler0 traceback = self._traceback self._settle_promise0(self._rejection_handler0, reason...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
456
470
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,849
_resolve_from_executor
def _resolve_from_executor(self, executor): # type: (Callable[[Callable[[T], None], Callable[[Exception], None]], None]) -> None # self._capture_stacktrace() synchronous = True def resolve(value): # type: (T) -> None self._resolve_callback(value) def rej...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
472
496
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,850
resolve
def resolve(value): # type: (T) -> None self._resolve_callback(value)
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
477
479
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,851
reject
def reject(reason, traceback=None): # type: (Exception, TracebackType) -> None self._reject_callback(reason, synchronous, traceback)
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
481
483
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,852
wait
def wait(cls, promise, timeout=None): # type: (Promise, Optional[float]) -> None async_instance.wait(promise, timeout)
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
499
501
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,853
_wait
def _wait(self, timeout=None): # type: (Optional[float]) -> None self.wait(self, timeout)
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
503
505
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,854
get
def get(self, timeout=None): # type: (Optional[float]) -> T target = self._target() self._wait(timeout or DEFAULT_TIMEOUT) return self._target_settled_value(_raise=True)
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
507
511
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,855
_target_settled_value
def _target_settled_value(self, _raise=False): # type: (bool) -> Any return self._target()._settled_value(_raise)
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
513
515
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,856
__repr__
def __repr__(self): # type: () -> str hex_id = hex(id(self)) if self._is_following: return "<Promise at {} following {}>".format(hex_id, self._target()) state = self._state if state == STATE_PENDING: return "<Promise at {} pending>".format(hex_id) ...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
520
537
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,857
is_pending
def is_pending(self): # type: (Promise) -> bool """Indicate whether the Promise is still pending. Could be wrong the moment the function returns.""" return self._target()._state == STATE_PENDING
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
540
543
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,858
is_fulfilled
def is_fulfilled(self): # type: (Promise) -> bool """Indicate whether the Promise has been fulfilled. Could be wrong the moment the function returns.""" return self._target()._state == STATE_FULFILLED
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
546
549
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,859
is_rejected
def is_rejected(self): # type: (Promise) -> bool """Indicate whether the Promise has been rejected. Could be wrong the moment the function returns.""" return self._target()._state == STATE_REJECTED
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
552
555
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,860
catch
def catch(self, on_rejection): # type: (Promise, Callable[[Exception], Any]) -> Promise """ This method returns a Promise and deals with rejected cases only. It behaves the same as calling Promise.then(None, on_rejection). """ return self.then(None, on_rejection)
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
557
563
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,861
_then
def _then( self, did_fulfill=None, # type: Optional[Callable[[T], S]] did_reject=None, # type: Optional[Callable[[Exception], S]] ): # type: (...) -> Promise[S] promise = self.__class__() # type: Promise target = self._target() state = target._state ...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
565
595
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,862
then
def then(self, did_fulfill=None, did_reject=None): # type: (Promise, Callable[[T], S], Optional[Callable[[Exception], S]]) -> Promise[S] """ This method takes two optional arguments. The first argument is used if the "self promise" is fulfilled and the other is used if the "self...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
601
629
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,863
done
def done(self, did_fulfill=None, did_reject=None): # type: (Optional[Callable], Optional[Callable]) -> None promise = self._then(did_fulfill, did_reject) promise._is_final = True
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
631
634
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,864
done_all
def done_all(self, handlers=None): # type: (Promise, Optional[List[Union[Dict[str, Optional[Callable]], Tuple[Callable, Callable], Callable]]]) -> None """ :type handlers: list[(Any) -> object] | list[((Any) -> object, (Any) -> object)] """ if not handlers: return ...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
636
654
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,865
then_all
def then_all(self, handlers=None): # type: (Promise, List[Callable]) -> List[Promise] """ Utility function which calls 'then' for each handler provided. Handler can either be a function in which case it is used as success handler, or a tuple containing the success and the failure...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
656
684
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,866
_try_convert_to_promise
def _try_convert_to_promise(cls, obj): # type: (Any) -> Promise _type = obj.__class__ if issubclass(_type, Promise): if cls is not Promise: return cls(obj.then, obj._scheduler) return obj if iscoroutine(obj): # type: ignore obj = ensu...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
687
713
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,867
executor
def executor(resolve, reject): # type: (Callable, Callable) -> None if obj.done(): _process_future_result(resolve, reject)(obj) else: obj.add_done_callback(_process_future_result(resolve, reject)) # _process_future_r...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
701
707
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,868
reject
def reject(cls, reason): # type: (Exception) -> Promise ret = cls() # type: Promise # ret._capture_stacktrace(); # ret._rejectCallback(reason, true); ret._reject_callback(reason, True) return ret
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
716
722
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,869
resolve
def resolve(cls, obj): # type: (T) -> Promise[T] if not cls.is_thenable(obj): ret = cls() # type: Promise # ret._capture_stacktrace() ret._state = STATE_FULFILLED ret._rejection_handler0 = obj return ret return cls._try_convert_to_pro...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
727
736
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,870
promisify
def promisify(cls, f): # type: (Callable) -> Callable[..., Promise] if not callable(f): warn( "Promise.promisify is now a function decorator, please use Promise.resolve instead." ) return cls.resolve(f) @wraps(f) def wrapper(*args, **k...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
742
759
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,871
wrapper
def wrapper(*args, **kwargs): # type: (*Any, **Any) -> Promise def executor(resolve, reject): # type: (Callable, Callable) -> Optional[Any] return resolve(f(*args, **kwargs)) return cls(executor)
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
751
757
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,872
executor
def executor(resolve, reject): # type: (Callable, Callable) -> Optional[Any] return resolve(f(*args, **kwargs))
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
753
755
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,873
safe
def safe(cls, fn): # type: (Callable) -> Callable from functools import wraps if not cls._safe_resolved_promise: cls._safe_resolved_promise = Promise.resolve(None) @wraps(fn) def wrapper(*args, **kwargs): # type: (*Any, **Any) -> Promise retu...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
764
776
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,874
wrapper
def wrapper(*args, **kwargs): # type: (*Any, **Any) -> Promise return cls._safe_resolved_promise.then(lambda v: fn(*args, **kwargs))
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
772
774
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,875
all
def all(cls, promises): # type: (Any) -> Promise return PromiseList(promises, promise_class=cls).promise
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
779
781
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,876
for_dict
def for_dict(cls, m): # type: (Dict[Hashable, Promise[S]]) -> Promise[Dict[Hashable, S]] """ A special function that takes a dictionary of promises and turns them into a promise for a dictionary of values. In other words, this turns an dictionary of promises for values in...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
784
801
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,877
handle_success
def handle_success(resolved_values): # type: (List[S]) -> Dict[Hashable, S] return dict_type(zip(m.keys(), resolved_values))
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
797
799
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,878
is_thenable
def is_thenable(cls, obj): # type: (Any) -> bool """ A utility function to determine if the specified object is a promise using "duck typing". """ _type = obj.__class__ if obj is None or _type in BASE_TYPES: return False return ( i...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
804
818
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,879
is_future_like
def is_future_like(_type): # type: (type) -> bool if _type not in _type_done_callbacks: _type_done_callbacks[_type] = callable( getattr(_type, "add_done_callback", None) ) return _type_done_callbacks[_type]
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
824
830
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,880
_process_future_result
def _process_future_result(resolve, reject): # type: (Callable, Callable) -> Callable def handle_future_result(future): # type: (Any) -> None try: resolve(future.result()) except Exception as e: tb = exc_info()[2] reject(e, tb) return handle_futur...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
838
848
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,881
handle_future_result
def handle_future_result(future): # type: (Any) -> None try: resolve(future.result()) except Exception as e: tb = exc_info()[2] reject(e, tb)
python
wandb/vendor/promise-2.3.0/wandb_promise/promise.py
840
846
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,882
iscoroutine
def iscoroutine(obj): # type: ignore return False
python
wandb/vendor/promise-2.3.0/wandb_promise/compat.py
5
6
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,883
__init__
def __init__(self): raise Exception("You need asyncio for using Futures")
python
wandb/vendor/promise-2.3.0/wandb_promise/compat.py
14
15
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,884
set_result
def set_result(self): raise Exception("You need asyncio for using Futures")
python
wandb/vendor/promise-2.3.0/wandb_promise/compat.py
17
18
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,885
set_exception
def set_exception(self): raise Exception("You need asyncio for using Futures")
python
wandb/vendor/promise-2.3.0/wandb_promise/compat.py
20
21
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,886
ensure_future
def ensure_future(): # type: ignore raise Exception("ensure_future needs asyncio for executing")
python
wandb/vendor/promise-2.3.0/wandb_promise/compat.py
23
24
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,887
iterate_promise
def iterate_promise(promise): # type: ignore raise Exception('You need "yield from" syntax for iterate in a Promise.')
python
wandb/vendor/promise-2.3.0/wandb_promise/compat.py
31
32
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,888
warn
def warn(msg): # type: (str) -> None warnings.simplefilter("always", DeprecationWarning) # turn off filter warnings.warn(msg, category=DeprecationWarning, stacklevel=2) warnings.simplefilter("default", DeprecationWarning) # reset filter
python
wandb/vendor/promise-2.3.0/wandb_promise/utils.py
8
12
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,889
__init__
def __init__(self, reason, name=None): if inspect.isclass(reason) or inspect.isfunction(reason): raise TypeError("Reason for deprecation must be supplied") self.reason = reason self.name = name
python
wandb/vendor/promise-2.3.0/wandb_promise/utils.py
16
20
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,890
__call__
def __call__(self, cls_or_func): if inspect.isfunction(cls_or_func): fmt = "Call to deprecated function or method {name} ({reason})." elif inspect.isclass(cls_or_func): fmt = "Call to deprecated class {name} ({reason})." else: raise TypeError(type(cls_or_fun...
python
wandb/vendor/promise-2.3.0/wandb_promise/utils.py
22
39
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,891
new_func
def new_func(*args, **kwargs): warn(msg) return cls_or_func(*args, **kwargs)
python
wandb/vendor/promise-2.3.0/wandb_promise/utils.py
35
37
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,892
__init__
def __init__(self, values, promise_class): # type: (Union[Collection, Promise[Collection]], Type[Promise]) -> None self._promise_class = promise_class self.promise = self._promise_class() self._length = 0 self._total_resolved = 0 self._values = None # type: Optional[Col...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise_list.py
24
39
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,893
__len__
def __len__(self): # type: () -> int return self._length
python
wandb/vendor/promise-2.3.0/wandb_promise/promise_list.py
41
43
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,894
_init_promise
def _init_promise(self, values): # type: (Promise[Collection]) -> None if values.is_fulfilled: values = values._value() elif values.is_rejected: self._reject(values._reason()) return self.promise._is_async_guaranteed = True values._then(self._...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise_list.py
45
55
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,895
_init
def _init(self, values): # type: (Collection) -> None self._values = values if not isinstance(values, Iterable): err = Exception( "PromiseList requires an iterable. Received {}.".format(repr(values)) ) self.promise._reject_callback(err, False) ...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise_list.py
57
72
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,896
_iterate
def _iterate(self, values): # type: (Collection[Any]) -> None Promise = self._promise_class is_resolved = False self._length = len(values) self._values = [None] * self._length result = self.promise for i, val in enumerate(values): if Promise.is_then...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise_list.py
74
109
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,897
_promise_fulfilled
def _promise_fulfilled(self, value, i): # type: (Any, int) -> bool if self.is_resolved: return False # assert not self.is_resolved # assert isinstance(self._values, Iterable) # assert isinstance(i, int) self._values[i] = value # type: ignore self._tot...
python
wandb/vendor/promise-2.3.0/wandb_promise/promise_list.py
111
123
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,898
_promise_rejected
def _promise_rejected(self, reason): # type: (Exception) -> bool if self.is_resolved: return False # assert not self.is_resolved # assert isinstance(self._values, Iterable) self._total_resolved += 1 self._reject(reason) return True
python
wandb/vendor/promise-2.3.0/wandb_promise/promise_list.py
125
133
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,899
is_resolved
def is_resolved(self): # type: () -> bool return self._values is None
python
wandb/vendor/promise-2.3.0/wandb_promise/promise_list.py
136
138
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
7,900
_resolve
def _resolve(self, value): # type: (Collection[Any]) -> None assert not self.is_resolved assert not isinstance(value, self._promise_class) self._values = None self.promise._fulfill(value)
python
wandb/vendor/promise-2.3.0/wandb_promise/promise_list.py
140
145
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }