def server_instance_class(monkeysession, tmp_path_factory, worker_id): from secrets import choice from hangar.remote import server monkeysession.setattr(server, 'server_config', mock_server_config) monkeysession.setitem(hangar.constants.LMDB_SETTINGS, 'map_size', 2_000_000) monkeysession.setitem(hangar.backends.lmdb_30.LMDB_SETTINGS, 'map_size', 1_000_000) monkeysession.setitem(hangar.backends.lmdb_31.LMDB_SETTINGS, 'map_size', 1_000_000) monkeysession.setattr(hangar.backends.hdf5_00, 'COLLECTION_COUNT', 20) monkeysession.setattr(hangar.backends.hdf5_00, 'COLLECTION_SIZE', 20) monkeysession.setattr(hangar.backends.hdf5_01, 'COLLECTION_COUNT', 20) monkeysession.setattr(hangar.backends.hdf5_01, 'COLLECTION_SIZE', 20) monkeysession.setattr(hangar.backends.numpy_10, 'COLLECTION_SIZE', 100) possibble_addresses = [x for x in range(50000, 59999)] chosen_address = choice(possibble_addresses) address = f'localhost:{chosen_address}' base_tmpdir = tmp_path_factory.mktemp(f'{worker_id[-1]}') server, hangserver, _ = server.serve(str(base_tmpdir), overwrite=True, channel_address=address) server.start() yield address hangserver.close() server.stop(0.1) server.wait_for_termination(timeout=2)
def server_instance(monkeypatch, managed_tmpdir, worker_id): from secrets import choice from hangar.remote import server monkeypatch.setattr(server, 'server_config', mock_server_config) possibble_addresses = [x for x in range(50000, 59999)] chosen_address = choice(possibble_addresses) address = f'localhost:{chosen_address}' base_tmpdir = pjoin(managed_tmpdir, f'{worker_id[-1]}') mkdir(base_tmpdir) server, hangserver, _ = server.serve(base_tmpdir, overwrite=True, channel_address=address) server.start() yield address hangserver.close() server.stop(0.1) server.wait_for_termination(timeout=2)
def server_instance_push_restricted(monkeypatch, managed_tmpdir, worker_id): from hangar.remote import server from secrets import choice monkeypatch.setattr(server, 'server_config', mock_server_config) possibble_addresses = [x for x in range(50000, 59999)] chosen_address = choice(possibble_addresses) address = f'localhost:{chosen_address}' base_tmpdir = pjoin(managed_tmpdir, f'{worker_id[-1]}') mkdir(base_tmpdir) server, hangserver, _ = server.serve(base_tmpdir, overwrite=True, channel_address=address, restrict_push=True, username='******', password='******') server.start() yield address hangserver.env._close_environments() hangserver.close() server.stop(0.1) server.wait_for_termination(timeout=2)