Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into release/cli-0.10.0rc
Browse files Browse the repository at this point in the history
  • Loading branch information
raubitsj committed Aug 26, 2020
2 parents e34098f + e3710e4 commit e8ae248
Show file tree
Hide file tree
Showing 73 changed files with 4,481 additions and 1,730 deletions.
File renamed without changes.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ test-clean:
rm -rf .tox/
rm -rf .pytest_cache/

test:
tox -e "codemod,black,mypy,flake8"

test-full:
tox

clean-pyc: ## remove Python file artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# ** Client - Next Generation**
<div align="center">
<img src="https://i.imgur.com/RUtiVzH.png" width="600" /><br><br>
<img src="https://i.imgur.com/dKqSdPi.png" width="600" /><br><br>
</div>

# **Experimental Client - Next Generation**
Try the latest version of W&B for machine learning experiment tracking. Install the new library with:

This repo contains experimental changes to the production wandb client at [github.com/wandb/client](http://github.com/wandb/client).

## Primary Features
```
pip install wandb --upgrade --pre
```

- Better support for different operating environments including windows and juypter
- Improved configurability (Documentation coming soon)
- Improved syncing and offline mode to support compute nodes without internet connection (Not in current release)
Why should I switch to the new CLI?
- Better support for Windows and Jupyter notebooks
- Preview the upcoming release and share feedback

## Support

Expand Down
2 changes: 1 addition & 1 deletion pydoc-markdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ renderer:
pages:
- title: Developer Documentation
name: index
source: README-dev.md
source: CONTRIBUTING.md
- title: SDK Documentation
contents:
- 'wandb'
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ include = '''
| wandb/server/
| wandb/integration/gym/
| wandb/integration/tensorboard/
| wandb/cli/
| wandb/integration/magic.py
| wandb/integration/keras
'''
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ gql==0.2.0
python-dateutil>=2.6.1
requests>=2.0.0
shortuuid>=0.5.0
six>=1.10.0
six>=1.13.0
watchdog>=0.8.3
psutil>=5.0.0
sentry-sdk>=0.4.0
Expand Down
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ pydoc-markdown
torch; python_version >= '3.5' and sys_platform == 'darwin'
torchvision; python_version >= '3.5' and sys_platform == 'darwin'
torch==1.5.1+cpu; python_version >= '3.5' and sys_platform != 'darwin'
torchvision==0.6.1+cpu; python_version >= '3.5' and sys_platform != 'darwin'
torchvision==0.6.1+cpu; python_version >= '3.5' and sys_platform != 'darwin'
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import atexit
import wandb
from wandb.lib.module import unset_globals
from wandb.internal.git_repo import GitRepo
from wandb.lib.git import GitRepo
from wandb.util import mkdir_exists_ok
from six.moves import urllib
try:
Expand Down Expand Up @@ -298,7 +298,7 @@ def wandb_init_run(request, runner, mocker, mock_server):
# We want to run setup every time in tests
wandb.wandb_sdk.wandb_setup._WandbSetup._instance = None
mocker.patch('wandb.wandb_sdk.wandb_init.Backend', utils.BackendMock)
run = wandb.init(settings=wandb.Settings(console="off", offline=True),
run = wandb.init(settings=wandb.Settings(console="off", offline=True, _except_exit=False),
**args["wandb_init"])
yield run
wandb.join()
Expand Down
36 changes: 36 additions & 0 deletions tests/sample_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""sample tests."""

from __future__ import print_function

import pytest
from wandb.internal import sample

def doit(num, samples=None):
s = sample.UniformSampleAccumulator(min_samples=samples)
for n in range(num):
s.add(n)
return s.get()


def diff(l):
d = []
for n, v in enumerate(l[1:]):
d.append(v-l[n])
return d


def check(n, l, samples):
d = diff(l)
diffs = set(d)
if len(l) < 2:
return
assert len(diffs) == 1
assert len(l) == n or (len(l) >= samples and len(l) <= samples * 3)


def test_all():
"""Try all."""
for s in range(1, 36, 7):
for n in range(1000):
l = doit(n, samples=s)
check(n, l, samples=s)
82 changes: 81 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,4 +640,84 @@ def test_local_already_running(runner, docker, local_settings):
result = runner.invoke(cli.local)
print(result.output)
print(traceback.print_tb(result.exc_info[2]))
assert "A container named wandb-local is already running" in result.output
assert "A container named wandb-local is already running" in result.output


def test_restore_no_remote(runner, mock_server, git_repo, docker, monkeypatch):
with open("patch.txt", "w") as f:
f.write("test")
git_repo.repo.index.add(["patch.txt"])
git_repo.repo.commit()
result = runner.invoke(cli.restore, ["wandb/test:abcdef"])
print(result.output)
print(traceback.print_tb(result.exc_info[2]))
assert result.exit_code == 0
assert "Created branch wandb/abcdef" in result.output
assert "Applied patch" in result.output
assert "Restored config variables to " in result.output
assert "Launching docker container" in result.output
docker.assert_called_with(['docker', 'run', '-e', 'LANG=C.UTF-8', '-e', 'WANDB_DOCKER=wandb/deepo@sha256:abc123', '--ipc=host', '-v',
wandb.docker.entrypoint+':/wandb-entrypoint.sh', '--entrypoint', '/wandb-entrypoint.sh', '-v', os.getcwd()+
':/app', '-w', '/app', '-e',
'WANDB_API_KEY=test', '-e', 'WANDB_COMMAND=python train.py --test foo', '-it', 'test/docker', '/bin/bash'])


def test_restore_bad_remote(runner, mock_server, git_repo, docker, monkeypatch):
# git_repo creates it's own isolated filesystem
mock_server.set_context("git", {"repo": "http://fake.git/foo/bar"})
api = InternalApi({'project': 'test'})
monkeypatch.setattr(cli, '_api', api)
def bad_commit(cmt):
raise ValueError()
monkeypatch.setattr(api.git.repo, 'commit', bad_commit)
monkeypatch.setattr(api, "download_urls", lambda *args, **kwargs: [])
result = runner.invoke(cli.restore, ["wandb/test:abcdef"])
print(result.output)
print(traceback.print_tb(result.exc_info[2]))
assert result.exit_code == 1
assert "Run `git clone http://fake.git/foo/bar`" in result.output


def test_restore_good_remote(runner, mock_server, git_repo, docker, monkeypatch):
# git_repo creates it's own isolated filesystem
git_repo.repo.create_remote('origin', "git@fake.git:foo/bar")
monkeypatch.setattr(subprocess, 'check_call', lambda command: True)
mock_server.set_context("git", {"repo": "http://fake.git/foo/bar"})
monkeypatch.setattr(cli, '_api', InternalApi({'project': 'test'}))
result = runner.invoke(cli.restore, ["wandb/test:abcdef"])
print(result.output)
print(traceback.print_tb(result.exc_info[2]))
assert result.exit_code == 0
assert "Created branch wandb/abcdef" in result.output


def test_restore_slashes(runner, mock_server, git_repo, docker, monkeypatch):
# git_repo creates it's own isolated filesystem
mock_server.set_context("git", {"repo": "http://fake.git/foo/bar"})
monkeypatch.setattr(cli, '_api', InternalApi({'project': 'test'}))
result = runner.invoke(cli.restore, ["wandb/test/abcdef", "--no-git"])
print(result.output)
print(traceback.print_tb(result.exc_info[2]))
assert result.exit_code == 0
assert "Restored config variables" in result.output


def test_restore_no_entity(runner, mock_server, git_repo, docker, monkeypatch):
# git_repo creates it's own isolated filesystem
mock_server.set_context("git", {"repo": "http://fake.git/foo/bar"})
monkeypatch.setattr(cli, '_api', InternalApi({'project': 'test'}))
result = runner.invoke(cli.restore, ["test/abcdef", "--no-git"])
print(result.output)
print(traceback.print_tb(result.exc_info[2]))
assert result.exit_code == 0
assert "Restored config variables" in result.output


def test_restore_not_git(runner, mock_server, docker, monkeypatch):
with runner.isolated_filesystem():
monkeypatch.setattr(cli, '_api', InternalApi({'project': 'test'}))
result = runner.invoke(cli.restore, ["test/abcdef"])
print(result.output)
print(traceback.print_tb(result.exc_info[2]))
assert result.exit_code == 0
assert "Original run has no git history" in result.output
2 changes: 1 addition & 1 deletion tests/test_git_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""
import platform
import pytest
from wandb.internal.git_repo import GitRepo
from wandb.lib.git import GitRepo


class TestGitRepo:
Expand Down
35 changes: 16 additions & 19 deletions tests/test_meta.py
Original file line number Diff line number Diff line change
@@ -1,53 +1,50 @@
import os
import pytest
import platform
import os
from six.moves import queue
import threading

from six.moves import queue
from wandb.internal.meta import Meta
from wandb.internal.sender import SendManager
from wandb.interface.interface import BackendSender


@pytest.fixture()
def process_q():
def record_q():
return queue.Queue()


@pytest.fixture()
def notify_q():
def result_q():
return queue.Queue()


@pytest.fixture()
def resp_q():
return queue.Queue()


@pytest.fixture()
def req_q():
return queue.Queue()
def interface(record_q):
return BackendSender(record_q=record_q)


@pytest.fixture()
def meta(test_settings, req_q):
return Meta(test_settings, req_q, queue.Queue())
def meta(test_settings, interface):
return Meta(settings=test_settings, interface=interface)


@pytest.fixture()
def sm(runner, git_repo, resp_q, test_settings, meta, mock_server, mocked_run, req_q):
def sm(runner, git_repo, record_q, result_q, test_settings, meta, mock_server, mocked_run, interface):
test_settings.root_dir = os.getcwd()
sm = SendManager(test_settings, process_q, notify_q, resp_q)
meta._interface.send_run(mocked_run)
sm.send(req_q.get())
sm = SendManager(settings=test_settings, record_q=record_q, result_q=result_q, interface=interface)
meta._interface.publish_run(mocked_run)
sm.send(record_q.get())
yield sm


@pytest.mark.skipif(platform.system() == "Windows", reason="git stopped working")
def test_meta_probe(mock_server, meta, sm, req_q):
def test_meta_probe(mock_server, meta, sm, record_q):
with open("README", "w") as f:
f.write("Testing")
meta.probe()
meta.write()
sm.send(req_q.get())
sm.send(record_q.get())
sm.finish()
print(mock_server.ctx)
assert len(mock_server.ctx["storage?file=wandb-metadata.json"]) == 1
Expand Down
Loading

0 comments on commit e8ae248

Please sign in to comment.