def test_init(git_repo, upsert_run, request_mocker): upsert_run(request_mocker) os.environ['WANDB_RUN_STORAGE_ID'] = 'abc' os.environ['WANDB_MODE'] = 'run' run = wandb.init() assert run.mode == "run" wandb.reset_env()
def pytest_runtest_setup(item): wandb.reset_env() wandb.uninit() global_settings = os.path.expanduser("~/.config/wandb/settings") if os.path.exists(global_settings): os.remove(global_settings) # This is used to find tests that are leaking outside of tmp directories os.environ["WANDB_DESCRIPTION"] = item.parent.name + "#" + item.name
def test_run_ignore_diff(runner, git_repo, mock_server, monkeypatch): run_id = "abc123" os.environ["WANDB_IGNORE_GLOBS"] = "*.patch" with open("simple.py", "w") as f: f.write('print("Done!")') with open("README", "w") as f: f.write("Making it dirty") print(os.getcwd()) result = runner.invoke( cli.run, ["--id=%s" % run_id, "python", "simple.py"]) print(result.output) print(result.exception) print(traceback.print_tb(result.exc_info[2])) # This is disabled for now because it hasn't worked for a long time: #assert "Verifying uploaded files... verified!" in result.output assert result.exit_code == 0 assert "Synced lovely-dawn-32" in result.output assert 'storage?file=diff.patch' not in mock_server.requests.keys() wandb.reset_env()
def run(self): import os import wandb wandb.uninit() wandb.reset_env() run = wandb.init(group=self.group_name, job_type='rollout') print('Worker started. wandb run ID: %s' % run.id) ep_rew = 0 ep_len = 0 while True: command, data = self.remote.recv() if command == 'step': observation, reward, done, info = ( self.empty_step() if self.done else self.env.step(data)) ep_rew += reward ep_len += 1 if done: wandb.log({'ep_rew': ep_rew, 'ep_len': ep_len}) ep_rew = 0 ep_len = 0 # print('Worker step: ', observation, data, reward, done, info) if done and (not self.done): observation = self.try_reset() self.remote.send( (observation, reward, done, self.task_id, info)) elif command == 'reset': observation = self.try_reset() self.remote.send((observation, self.task_id)) elif command == 'reset_task': self.env.unwrapped.reset_task(data) self.remote.send(True) elif command == 'close': self.remote.close() break elif command == 'get_spaces': self.remote.send( (self.env.observation_space, self.env.action_space)) else: raise NotImplementedError()