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
401
mocks_from_args
def mocks_from_args(mocker, args, mock_server): if args["k8s"] is not None: mock_server.ctx["k8s"] = args["k8s"] args["env"].update(utils.mock_k8s(mocker)) if args["sagemaker"]: args["env"].update(utils.mock_sagemaker(mocker))
python
tests/pytest_tests/unit_tests_old/conftest.py
475
480
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
402
wandb_init_run
def wandb_init_run(request, runner, mocker, mock_server): marker = request.node.get_closest_marker("wandb_args") args = default_wandb_args() if marker: args.update(marker.kwargs) try: mocks_from_args(mocker, args, mock_server) with mock.patch.dict(os.environ, {k: v for k, v in ar...
python
tests/pytest_tests/unit_tests_old/conftest.py
484
501
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
403
wandb_init
def wandb_init(request, runner, mocker, mock_server): def init(*args, **kwargs): try: mocks_from_args(mocker, default_wandb_args(), mock_server) # TODO: likely not the right thing to do, we shouldn't be setting this wandb._IS_INTERNAL_PROCESS = False return w...
python
tests/pytest_tests/unit_tests_old/conftest.py
505
519
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
404
init
def init(*args, **kwargs): try: mocks_from_args(mocker, default_wandb_args(), mock_server) # TODO: likely not the right thing to do, we shouldn't be setting this wandb._IS_INTERNAL_PROCESS = False return wandb.init( settings=dict(console="off", mo...
python
tests/pytest_tests/unit_tests_old/conftest.py
506
517
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
405
restore_version
def restore_version(): save_current_version = wandb.__version__ yield wandb.__version__ = save_current_version try: del wandb.__hack_pypi_latest_version__ except AttributeError: pass
python
tests/pytest_tests/unit_tests_old/conftest.py
523
530
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
406
parse_ctx
def parse_ctx(): """Fixture providing class to parse context data.""" def parse_ctx_fn(ctx, run_id=None): return utils.ParseCTX(ctx, run_id=run_id) yield parse_ctx_fn
python
tests/pytest_tests/unit_tests_old/conftest.py
534
540
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
407
parse_ctx_fn
def parse_ctx_fn(ctx, run_id=None): return utils.ParseCTX(ctx, run_id=run_id)
python
tests/pytest_tests/unit_tests_old/conftest.py
537
538
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
408
record_q
def record_q(): return queue.Queue()
python
tests/pytest_tests/unit_tests_old/conftest.py
544
545
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
409
fake_interface
def fake_interface(record_q): return InterfaceQueue(record_q=record_q)
python
tests/pytest_tests/unit_tests_old/conftest.py
549
550
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
410
fake_backend
def fake_backend(fake_interface): class FakeBackend: def __init__(self): self.interface = fake_interface yield FakeBackend()
python
tests/pytest_tests/unit_tests_old/conftest.py
554
559
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
411
__init__
def __init__(self): self.interface = fake_interface
python
tests/pytest_tests/unit_tests_old/conftest.py
556
557
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
412
fake_run
def fake_run(fake_backend): def run_fn(): s = wandb.Settings() run = wandb_sdk.wandb_run.Run(settings=s) run._set_backend(fake_backend) return run yield run_fn
python
tests/pytest_tests/unit_tests_old/conftest.py
563
570
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
413
run_fn
def run_fn(): s = wandb.Settings() run = wandb_sdk.wandb_run.Run(settings=s) run._set_backend(fake_backend) return run
python
tests/pytest_tests/unit_tests_old/conftest.py
564
568
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
414
records_util
def records_util(): def records_fn(q): ru = utils.RecordsUtil(q) return ru yield records_fn
python
tests/pytest_tests/unit_tests_old/conftest.py
574
579
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
415
records_fn
def records_fn(q): ru = utils.RecordsUtil(q) return ru
python
tests/pytest_tests/unit_tests_old/conftest.py
575
577
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
416
user_test
def user_test(fake_run, record_q, records_util): class UserTest: pass ut = UserTest() ut.get_run = fake_run ut.get_records = lambda: records_util(record_q) yield ut
python
tests/pytest_tests/unit_tests_old/conftest.py
583
591
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
417
log_debug
def log_debug(caplog): caplog.set_level(logging.DEBUG) yield # for rec in caplog.records: # print("LOGGER", rec.message, file=sys.stderr)
python
tests/pytest_tests/unit_tests_old/conftest.py
603
607
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
418
internal_result_q
def internal_result_q(): return queue.Queue()
python
tests/pytest_tests/unit_tests_old/conftest.py
616
617
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
419
internal_sender_q
def internal_sender_q(): return queue.Queue()
python
tests/pytest_tests/unit_tests_old/conftest.py
621
622
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
420
internal_writer_q
def internal_writer_q(): return queue.Queue()
python
tests/pytest_tests/unit_tests_old/conftest.py
626
627
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
421
internal_process
def internal_process(): # FIXME: return mocked process (needs is_alive()) return MockProcess()
python
tests/pytest_tests/unit_tests_old/conftest.py
631
633
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
422
__init__
def __init__(self): self._alive = True
python
tests/pytest_tests/unit_tests_old/conftest.py
637
638
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
423
is_alive
def is_alive(self): return self._alive
python
tests/pytest_tests/unit_tests_old/conftest.py
640
641
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
424
internal_mailbox
def internal_mailbox(): return Mailbox()
python
tests/pytest_tests/unit_tests_old/conftest.py
645
646
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
425
_internal_sender
def _internal_sender(record_q, internal_result_q, internal_process, internal_mailbox): return InterfaceQueue( record_q=record_q, result_q=internal_result_q, process=internal_process, mailbox=internal_mailbox, )
python
tests/pytest_tests/unit_tests_old/conftest.py
650
656
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
426
_internal_context_keeper
def _internal_context_keeper(): context_keeper = context.ContextKeeper() yield context_keeper
python
tests/pytest_tests/unit_tests_old/conftest.py
660
662
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
427
internal_sm
def internal_sm( runner, internal_sender_q, internal_result_q, test_settings, mock_server, _internal_sender, _internal_context_keeper, tmp_path, ): with runner.isolated_filesystem(**get_temp_dir_kwargs(tmp_path)): test_settings.update( root_dir=os.getcwd(), source...
python
tests/pytest_tests/unit_tests_old/conftest.py
666
687
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
428
stopped_event
def stopped_event(): stopped = threading.Event() yield stopped
python
tests/pytest_tests/unit_tests_old/conftest.py
691
693
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
429
internal_hm
def internal_hm( runner, record_q, internal_result_q, test_settings, mock_server, internal_writer_q, _internal_sender, stopped_event, _internal_context_keeper, tmp_path, ): with runner.isolated_filesystem(**get_temp_dir_kwargs(tmp_path)): test_settings.update( ...
python
tests/pytest_tests/unit_tests_old/conftest.py
697
722
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
430
internal_wm
def internal_wm( runner, internal_writer_q, internal_result_q, internal_sender_q, stopped_event, _internal_sender, _internal_context_keeper, test_settings, tmp_path, ): with runner.isolated_filesystem(**get_temp_dir_kwargs(tmp_path)): test_settings.update( roo...
python
tests/pytest_tests/unit_tests_old/conftest.py
726
752
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
431
internal_get_record
def internal_get_record(): def _get_record(input_q, timeout=None): try: i = input_q.get(timeout=timeout) except queue.Empty: return None return i return _get_record
python
tests/pytest_tests/unit_tests_old/conftest.py
756
764
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
432
_get_record
def _get_record(input_q, timeout=None): try: i = input_q.get(timeout=timeout) except queue.Empty: return None return i
python
tests/pytest_tests/unit_tests_old/conftest.py
757
762
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
433
start_send_thread
def start_send_thread( internal_sender_q, internal_get_record, stopped_event, internal_process ): def start_send(send_manager): def target(): try: while True: payload = internal_get_record( input_q=internal_sender_q, timeout=0.1 ...
python
tests/pytest_tests/unit_tests_old/conftest.py
768
794
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
434
start_send
def start_send(send_manager): def target(): try: while True: payload = internal_get_record( input_q=internal_sender_q, timeout=0.1 ) if payload: send_manager.send(payload) ...
python
tests/pytest_tests/unit_tests_old/conftest.py
771
791
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
435
target
def target(): try: while True: payload = internal_get_record( input_q=internal_sender_q, timeout=0.1 ) if payload: send_manager.send(payload) elif stopped_event.is_...
python
tests/pytest_tests/unit_tests_old/conftest.py
772
785
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
436
start_write_thread
def start_write_thread( internal_writer_q, internal_get_record, stopped_event, internal_process ): def start_write(write_manager): def target(): try: while True: payload = internal_get_record( input_q=internal_writer_q, timeout=0.1 ...
python
tests/pytest_tests/unit_tests_old/conftest.py
798
824
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
437
start_write
def start_write(write_manager): def target(): try: while True: payload = internal_get_record( input_q=internal_writer_q, timeout=0.1 ) if payload: write_manager.write(payload) ...
python
tests/pytest_tests/unit_tests_old/conftest.py
801
821
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
438
target
def target(): try: while True: payload = internal_get_record( input_q=internal_writer_q, timeout=0.1 ) if payload: write_manager.write(payload) elif stopped_event.i...
python
tests/pytest_tests/unit_tests_old/conftest.py
802
815
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
439
start_handle_thread
def start_handle_thread(record_q, internal_get_record, stopped_event): def start_handle(handle_manager): def target(): while True: payload = internal_get_record(input_q=record_q, timeout=0.1) if payload: handle_manager.handle(payload) ...
python
tests/pytest_tests/unit_tests_old/conftest.py
828
845
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
440
start_handle
def start_handle(handle_manager): def target(): while True: payload = internal_get_record(input_q=record_q, timeout=0.1) if payload: handle_manager.handle(payload) elif stopped_event.is_set(): break t = ...
python
tests/pytest_tests/unit_tests_old/conftest.py
829
842
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
441
target
def target(): while True: payload = internal_get_record(input_q=record_q, timeout=0.1) if payload: handle_manager.handle(payload) elif stopped_event.is_set(): break
python
tests/pytest_tests/unit_tests_old/conftest.py
830
836
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
442
_start_backend
def _start_backend( mocked_run, internal_hm, internal_sm, internal_wm, _internal_sender, start_handle_thread, start_write_thread, start_send_thread, log_debug, ): def start_backend_func(initial_run=True, initial_start=False): ht = start_handle_thread(internal_hm) ...
python
tests/pytest_tests/unit_tests_old/conftest.py
849
870
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
443
start_backend_func
def start_backend_func(initial_run=True, initial_start=False): ht = start_handle_thread(internal_hm) wt = start_write_thread(internal_wm) st = start_send_thread(internal_sm) if initial_run: run = _internal_sender.communicate_run(mocked_run) if initial_start: ...
python
tests/pytest_tests/unit_tests_old/conftest.py
860
868
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
444
_stop_backend
def _stop_backend( mocked_run, internal_hm, internal_sm, _internal_sender, start_handle_thread, start_send_thread, collect_responses, ): def stop_backend_func(threads=None): threads = threads or () handle = _internal_sender.deliver_exit(0) record = handle.wait(ti...
python
tests/pytest_tests/unit_tests_old/conftest.py
874
899
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
445
stop_backend_func
def stop_backend_func(threads=None): threads = threads or () handle = _internal_sender.deliver_exit(0) record = handle.wait(timeout=30) assert record server_info_handle = _internal_sender.deliver_request_server_info() result = server_info_handle.wait(timeout=30) ...
python
tests/pytest_tests/unit_tests_old/conftest.py
883
897
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
446
backend_interface
def backend_interface(_start_backend, _stop_backend, _internal_sender): @contextmanager def backend_context(initial_run=True, initial_start=False): threads = _start_backend(initial_run=initial_run, initial_start=initial_start) try: yield _internal_sender finally: ...
python
tests/pytest_tests/unit_tests_old/conftest.py
903
912
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
447
backend_context
def backend_context(initial_run=True, initial_start=False): threads = _start_backend(initial_run=initial_run, initial_start=initial_start) try: yield _internal_sender finally: _stop_backend(threads=threads)
python
tests/pytest_tests/unit_tests_old/conftest.py
905
910
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
448
publish_util
def publish_util( mocked_run, mock_server, backend_interface, parse_ctx, ): def fn( metrics=None, history=None, artifacts=None, files=None, begin_cb=None, end_cb=None, initial_start=False, ): metrics = metrics or [] history ...
python
tests/pytest_tests/unit_tests_old/conftest.py
916
952
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
449
fn
def fn( metrics=None, history=None, artifacts=None, files=None, begin_cb=None, end_cb=None, initial_start=False, ): metrics = metrics or [] history = history or [] artifacts = artifacts or [] files = files or [] with ba...
python
tests/pytest_tests/unit_tests_old/conftest.py
922
950
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
450
tbwatcher_util
def tbwatcher_util(mocked_run, mock_server, internal_hm, backend_interface, parse_ctx): def fn(write_function, logdir="./", save=True, root_dir="./"): with backend_interface() as interface: proto_run = pb.RunRecord() mocked_run._make_proto_run(proto_run) run_start = pb....
python
tests/pytest_tests/unit_tests_old/conftest.py
956
981
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
451
fn
def fn(write_function, logdir="./", save=True, root_dir="./"): with backend_interface() as interface: proto_run = pb.RunRecord() mocked_run._make_proto_run(proto_run) run_start = pb.RunStartRequest() run_start.run.CopyFrom(proto_run) request = pb.Re...
python
tests/pytest_tests/unit_tests_old/conftest.py
957
979
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
452
inject_requests
def inject_requests(mock_server): """Fixture for injecting responses and errors to mock_server.""" # TODO(jhr): make this compatible with live_mock_server return utils.InjectRequests(ctx=mock_server.ctx)
python
tests/pytest_tests/unit_tests_old/conftest.py
985
989
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
453
collect_responses
def collect_responses(): responses = Responses() yield responses
python
tests/pytest_tests/unit_tests_old/conftest.py
997
999
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
454
mock_tty
def mock_tty(monkeypatch): class WriteThread(threading.Thread): def __init__(self, fname): threading.Thread.__init__(self) self._fname = fname self._q = queue.Queue() def run(self): with open(self._fname, "w") as fp: while True: ...
python
tests/pytest_tests/unit_tests_old/conftest.py
1,003
1,058
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
455
__init__
def __init__(self, fname): threading.Thread.__init__(self) self._fname = fname self._q = queue.Queue()
python
tests/pytest_tests/unit_tests_old/conftest.py
1,005
1,008
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
456
run
def run(self): with open(self._fname, "w") as fp: while True: data = self._q.get() if data == "_DONE_": break fp.write(data) fp.flush()
python
tests/pytest_tests/unit_tests_old/conftest.py
1,010
1,017
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
457
add
def add(self, input_str): self._q.put(input_str)
python
tests/pytest_tests/unit_tests_old/conftest.py
1,019
1,020
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
458
stop
def stop(self): self.add("_DONE_")
python
tests/pytest_tests/unit_tests_old/conftest.py
1,022
1,023
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
459
setup_fn
def setup_fn(input_str): fname = os.path.join(tmpdir, "file.txt") if platform.system() != "Windows": os.mkfifo(fname, 0o600) writer = WriteThread(fname) writer.start() writer.add(input_str) fds["writer"] = writer ...
python
tests/pytest_tests/unit_tests_old/conftest.py
1,028
1,045
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
460
api
def api(runner): return Api()
python
tests/pytest_tests/unit_tests_old/conftest.py
1,062
1,063
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
461
get_step_metric_dict
def get_step_metric_dict(ml): """Get mapping from metric to preferred x-axis.""" nl = [m["1"] for m in ml] md = {m["1"]: nl[m["5"] - 1] for m in ml if m.get("5")} return md
python
tests/pytest_tests/unit_tests_old/utils/parse_metrics.py
25
29
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
462
matplotlib_multiple_axes_figures
def matplotlib_multiple_axes_figures(total_plot_count=3, data=[1, 2, 3]): """Helper generator which create a figure containing up to `total_plot_count` axes and optionally adds `data` to each axes in a permutation-style loop. """ for num_plots in range(1, total_plot_count + 1): for permutation ...
python
tests/pytest_tests/unit_tests_old/utils/dummy_data.py
9
25
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
463
matplotlib_with_image
def matplotlib_with_image(): """Create a matplotlib figure with an image""" fig, ax = plt.subplots(3) ax[0].plot([1, 2, 3]) ax[1].imshow(np.random.rand(200, 200, 3)) ax[2].plot([1, 2, 3]) return fig
python
tests/pytest_tests/unit_tests_old/utils/dummy_data.py
28
34
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
464
matplotlib_without_image
def matplotlib_without_image(): """Create a matplotlib figure without an image""" fig, ax = plt.subplots(2) ax[0].plot([1, 2, 3]) ax[1].plot([1, 2, 3]) return fig
python
tests/pytest_tests/unit_tests_old/utils/dummy_data.py
37
42
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
465
bokeh_plot
def bokeh_plot(): # from https://docs.bokeh.org/en/latest/docs/user_guide/quickstart.html # prepare some data x = [1, 2, 3, 4, 5] y = [6, 7, 2, 4, 5] # create a new plot with a title and axis labels p = figure(title="simple line example", x_axis_label="x", y_axis_label="y") # add a line re...
python
tests/pytest_tests/unit_tests_old/utils/dummy_data.py
45
57
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
466
execute_cells
def execute_cells(self, cell_index=0, execution_count=None, store_history=True): """Execute a specific cell. Since we always execute setup.py in the first cell we increment the index offset here """ if not isinstance(cell_index, list): cell_index = [cell_index] execu...
python
tests/pytest_tests/unit_tests_old/utils/notebook_client.py
6
37
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
467
execute_all
def execute_all(self, store_history=True): return self.execute_cells(list(range(len(self.nb["cells"]) - 1)), store_history)
python
tests/pytest_tests/unit_tests_old/utils/notebook_client.py
39
40
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
468
cell_output_text
def cell_output_text(self, cell_index): """Return cell text output Arguments: cell_index {int} -- cell index in notebook Returns: str -- Text output """ text = "" outputs = self.nb["cells"][cell_index + 1]["outputs"] for output in output...
python
tests/pytest_tests/unit_tests_old/utils/notebook_client.py
42
58
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
469
all_output_text
def all_output_text(self): text = "" for i in range(len(self.nb["cells"]) - 1): text += self.cell_output_text(i) return text
python
tests/pytest_tests/unit_tests_old/utils/notebook_client.py
60
64
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
470
cells
def cells(self): return iter(self.nb["cells"][1:])
python
tests/pytest_tests/unit_tests_old/utils/notebook_client.py
67
68
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
471
cell_output
def cell_output(self, cell_index): """Return a cells outputs NOTE: Since we always execute an init cell we adjust the offset by 1 Arguments: cell_index {int} -- cell index in notebook Returns: list -- List of outputs for the given cell """ outp...
python
tests/pytest_tests/unit_tests_old/utils/notebook_client.py
70
83
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
472
load_modules
def load_modules(use_yea=False): global RequestsMock, InjectRequestsParse, ArtifactEmulator if use_yea: from yea_wandb.artifact_emu import ArtifactEmulator from yea_wandb.mock_requests import InjectRequestsParse, RequestsMock else: try: from .artifact_emu import ArtifactE...
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
33
44
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
473
default_ctx
def default_ctx(): return { "fail_graphql_count": 0, # used via "fail_graphql_times" "fail_storage_count": 0, # used via "fail_storage_times" "rate_limited_count": 0, # used via "rate_limited_times" "graphql_conflict": False, "num_search_users": 1, "page_count": 0,...
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
51
107
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
474
mock_server
def mock_server(mocker): load_modules() ctx = default_ctx() app = create_app(ctx) mock = RequestsMock(app, ctx) # We mock out all requests libraries, couldn't find a way to mock the core lib sdk_path = "wandb.sdk" # From previous wandb_gql transport library. mocker.patch("wandb_gql.trans...
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
110
130
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
475
run
def run(ctx): if ctx["resume"]: now = datetime.now() created_at = (now - timedelta(days=1)).isoformat() else: created_at = datetime.now().isoformat() stopped = ctx.get("stopped", False) base_url = request.url_root.rstrip("/") # for wandb_tests::wandb_restore_name_not_found ...
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
133
227
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
476
artifact
def artifact( ctx, collection_name="mnist", state="COMMITTED", request_url_root="", id_override=None, ): _id = str(ctx["page_count"]) if id_override is None else id_override return { "id": _id, "digest": "abc123", "description": "", "state": state, "si...
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
230
266
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
477
paginated
def paginated(node, ctx, extra={}): next_page = False ctx["page_count"] += 1 if ctx["page_count"] < ctx["page_times"]: next_page = True edge = {"node": node, "cursor": "abc123"} edge.update(extra) return { "edges": [edge], "pageInfo": {"endCursor": "abc123", "hasNextPage"...
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
269
279
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
478
__init__
def __init__(self, ctx): self.ctx = ctx
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
291
292
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
479
get
def get(self): return self.ctx
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
294
295
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
480
set
def set(self, ctx): self.ctx = ctx CTX.persist(self) return self.ctx
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
297
300
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
481
persist
def persist(cls, instance): with cls.lock: cls.STATE = instance.ctx
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
303
305
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
482
load
def load(cls, default): with cls.lock: if cls.STATE is not None: return CTX(cls.STATE) else: return CTX(default)
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
308
313
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
483
get_ctx
def get_ctx(): if "ctx" not in g: g.ctx = CTX.load(default_ctx()) return g.ctx.get()
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
316
319
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
484
get_run_ctx
def get_run_ctx(run_id): glob_ctx = get_ctx() run_ctx = glob_ctx["runs"][run_id] return run_ctx
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
322
325
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
485
set_ctx
def set_ctx(ctx): get_ctx() g.ctx.set(ctx)
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
328
330
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
486
_bucket_config
def _bucket_config(ctx): files = ["wandb-metadata.json", "diff.patch"] if "bucket_config" in ctx and "files" in ctx["bucket_config"]: files = ctx["bucket_config"]["files"] base_url = request.url_root.rstrip("/") return { "commit": "HEAD", "github": "https://github.com/vanpelt", ...
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
333
358
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
487
__init__
def __init__(self, message, status_code=None, payload=None): Exception.__init__(self) self.message = message if status_code is not None: self.status_code = status_code self.payload = payload
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
364
369
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
488
to_dict
def to_dict(self): rv = dict(self.payload or ()) rv["error"] = self.message return rv
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
371
374
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
489
__init__
def __init__(self): self._inject_count = 0 self._inject_time = 0.0
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
381
383
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
490
relay
def relay(self, func): @functools.wraps(func) def wrapper(*args, **kwargs): # Normal mockserver mode, disable live relay and call next function if not os.environ.get("MOCKSERVER_RELAY"): return func(*args, **kwargs) if request.method == "POST": ...
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
385
434
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
491
wrapper
def wrapper(*args, **kwargs): # Normal mockserver mode, disable live relay and call next function if not os.environ.get("MOCKSERVER_RELAY"): return func(*args, **kwargs) if request.method == "POST": url_path = request.path body = reque...
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
387
432
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
492
context_enrich
def context_enrich(self, ctx): for run_id, run_info in ctx["relay_run_info"].items(): run_num = len(ctx["runs"]) insert = run_id not in ctx["run_ids"] if insert: ctx["run_ids"].append(run_id) run_ctx = ctx["runs"].setdefault(run_id, default_ctx()) ...
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
436
486
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
493
create_app
def create_app(user_ctx=None): app = Flask(__name__) # When starting in live mode, user_ctx is a fancy object if isinstance(user_ctx, dict): with app.app_context(): set_ctx(user_ctx) snoop = SnoopRelay() @app.teardown_appcontext def persist_ctx(exc): if "ctx" in g: ...
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
489
2,252
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
494
persist_ctx
def persist_ctx(exc): if "ctx" in g: CTX.persist(g.ctx)
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
498
500
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
495
handle_http_exception
def handle_http_exception(error): response = jsonify(error.to_dict()) # For azure storage response.headers["x-ms-error-code"] = 500 response.status_code = error.status_code return response
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
503
508
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
496
update_ctx
def update_ctx(): """Updating context for live_mock_server""" ctx = get_ctx() # in Flask/Werkzeug 2.1.0 get_json raises an exception on # empty json, so we try/catch here try: body = request.get_json() except BadRequest: body = None if req...
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
511
533
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
497
graphql
def graphql(): # TODO: in tests wandb-username is set to the test name, lets scope ctx to it ctx = get_ctx() base_url = request.url_root.rstrip("/") test_name = request.headers.get("X-WANDB-USERNAME") if test_name: app.logger.info("Test request from: %s", test_name) ...
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
537
1,787
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
498
storage
def storage(extra=None): ctx = get_ctx() if "fail_storage_times" in ctx: if ctx["fail_storage_count"] < ctx["fail_storage_times"]: ctx["fail_storage_count"] += 1 return json.dumps({"errors": ["Server down"]}), 500 file = request.args.get("file") ...
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
1,791
2,058
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
499
artifact_file
def artifact_file(entity, digest): if ART_EMU: return ART_EMU.file(entity=entity, digest=digest) if entity == "entity" or entity == "mock_server_entity": if ( digest == "d1a69a69a69a69a69a69a69a69a69a69" ): # "dataset.partitioned-table.json" ...
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
2,061
2,143
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
500
file_stream
def file_stream(entity, project, run): body = request.get_json() app.logger.info("file_stream post body: %s", body) ctx = get_ctx() run_ctx = get_run_ctx(run) for c in ctx, run_ctx: c["file_stream"] = c.get("file_stream", []) c["file_stream"].append(body)...
python
tests/pytest_tests/unit_tests_old/utils/mock_server.py
2,147
2,165
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }