Skip to content

Commit

Permalink
Merge branch 'Charlemagne_confusion_matrix' of https://github.com/wan…
Browse files Browse the repository at this point in the history
…db/client into Charlemagne_confusion_matrix
  • Loading branch information
KyleGoyette committed Nov 6, 2020
2 parents 36b2029 + 72cfa9b commit 1477d72
Show file tree
Hide file tree
Showing 23 changed files with 530 additions and 344 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
## 0.10.9 (November 4, 2020)

#### :nail_care: Enhancement

- Added artifact media logging (alpha)
- Add scriptable alerts
- Add url attribute for sweep public api
- Update docstrings for wandb sdk functions

#### :bug: Bug Fix

- Fix cases where offline mode was making network connections
- Fix issues with python sweeps and run stopping
- Fix logging issue where we could accidently display an api key
- Fix wandb login issues with malformed hosts
- Allow wandb.restore() to be called without wandb.init()
- Fix resuming (reusing run_id) with empty summary
- Fix artitifact download issue
- Add missing wandb.unwatch() function
- Avoid creating spurious wandb directories
- Fix collections import issue when using an old version of six

## 0.10.8 (October 22, 2020)

#### :nail_care: Enhancement
Expand Down
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.10.9.dev1
current_version = 0.10.10.dev1
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(?:\.dev(?P<dev>\d+))?
Expand All @@ -12,8 +12,8 @@ search = version='{current_version}'
replace = version='{new_version}'

[bumpversion:file:wandb/__init__.py]
search = __version__ = '{current_version}'
replace = __version__ = '{new_version}'
search = __version__ = "{current_version}"
replace = __version__ = "{new_version}"

[bdist_wheel]
universal = 1
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

setup(
name='wandb',
version='0.10.9.dev1',
version='0.10.10.dev1',
description="A CLI and library for interacting with the Weights and Biases API.",
long_description=readme,
long_description_content_type="text/markdown",
Expand Down
47 changes: 47 additions & 0 deletions standalone_tests/chdir_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env python
"""
Test for WB-3758.
"""

import os

import wandb


# test to ensure
run = wandb.init()
run_project = run.project
run_id = run.id
print("Started run {}/{}".format(run_project, run_id))

try:
os.makedirs('./chdir_test')
except Exception as e:
pass

os.chdir('./chdir_test')
# log some table data, which is saved in the media folder
pr_data = [
['setosa', 1.0, 1.0], ['setosa', 1.0, 1.0], ['setosa', 1.0, 1.0], ['setosa', 1.0, 1.0], ['setosa', 1.0, 1.0],
['setosa', 1.0, 1.0], ['setosa', 1.0, 1.0], ['setosa', 1.0, 1.0], ['setosa', 1.0, 1.0], ['setosa', 1.0, 1.0],
['setosa', 1.0, 0.0], ['setosa', 1.0, 0.0], ['setosa', 1.0, 0.0], ['setosa', 1.0, 0.0], ['setosa', 1.0, 0.0],
['setosa', 1.0, 0.0], ['setosa', 1.0, 0.0], ['setosa', 1.0, 0.0], ['setosa', 1.0, 0.0], ['setosa', 1.0, 0.0],
['versicolor', 1.0, 1.0], ['versicolor', 1.0, 1.0], ['versicolor', 1.0, 1.0], ['versicolor', 1.0, 1.0],
['versicolor', 1.0, 1.0], ['versicolor', 1.0, 1.0], ['versicolor', 1.0, 1.0], ['versicolor', 1.0, 1.0],
['versicolor', 1.0, 1.0], ['versicolor', 1.0, 1.0], ['versicolor', 1.0, 0.0], ['versicolor', 1.0, 0.0],
['versicolor', 1.0, 0.0], ['versicolor', 1.0, 0.0], ['versicolor', 1.0, 0.0], ['versicolor', 1.0, 0.0],
['versicolor', 1.0, 0.0], ['versicolor', 1.0, 0.0], ['versicolor', 1.0, 0.0], ['versicolor', 1.0, 0.0]
]

# convert the data to a table
pr_table = wandb.Table(data=pr_data, columns=["class", "precision", "recall"])
wandb.log({'pr_table': pr_table})
wandb.finish()

# Check results
api = wandb.Api()
last_run = api.run("%s/%s" % (run_project, run_id))
media_path = last_run.summary_metrics["pr_table"]["path"]
media_file = last_run.file(media_path)
assert media_file.size > 0
print("Success")
32 changes: 32 additions & 0 deletions tests/test_noop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""noop tests"""


from __future__ import print_function
import pytest
import wandb


def test_noop():
run = wandb.init(config={"foo": {"bar": {"x": "y"}}}, mode="disabled")
wandb.log({"x": {"y": "z"}})
wandb.log({"foo": {"bar": {"x": "y"}}})
assert wandb.run == run
assert wandb.config == run.config
assert wandb.summary == run.summary
assert run.config.foo["bar"]["x"] == "y"
assert wandb.summary["x"].y == "z"
assert wandb.summary["foo"].bar.x == "y"
wandb.summary.foo["bar"].update({"a": "b"})
assert wandb.summary.foo.bar.a == "b"


def test_bad_url(test_settings):
s = wandb.Settings(mode="disabled", base_url="localhost:9000")
test_settings._apply_settings(s)
run = wandb.init(settings=test_settings)
run.log({"acc": 0.9})
wandb.join()


if __name__ == "__main__":
pytest.main([__file__])
24 changes: 21 additions & 3 deletions tools/bumpversion-tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@


parser = argparse.ArgumentParser()
parser.add_argument("--dev", action="store_true", help="bump the dev version")
parser.add_argument("--to-dev", action="store_true", help="bump the dev version")
parser.add_argument("--from-dev", action="store_true", help="bump the dev version")
parser.add_argument("--debug", action="store_true", help="debug")
args = parser.parse_args()

Expand All @@ -34,18 +35,35 @@ def bump_release_to_dev(current_version):
new_version = "{}.{}.{}.dev1".format(major, minor, patch_num + 1)
bump_args = []
if args.debug:
bump_args += ["--allow-dirty", "--dry-run"]
bump_args += ["--allow-dirty", "--dry-run", "--verbose"]
bump_args += ["--new-version", new_version, "dev"]
bumpversion.main(bump_args)


def bump_release_from_dev(current_version):
# Assume this is a dev version
parts = current_version.split(".")
if len(parts) != 4:
version_problem(current_version)
major, minor, patch, _ = parts

new_version = "{}.{}.{}".format(major, minor, patch)
bump_args = []
if args.debug:
bump_args += ["--allow-dirty", "--dry-run", "--verbose"]
bump_args += ["--new-version", new_version, "patch"]
bumpversion.main(bump_args)


def main():
config = configparser.ConfigParser()
config.read("setup.cfg")
current_version = config["bumpversion"]["current_version"]

if args.dev:
if args.to_dev:
bump_release_to_dev(current_version)
elif args.from_dev:
bump_release_from_dev(current_version)
else:
parser.print_help()

Expand Down
12 changes: 10 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,21 @@ deps =
commands=
/bin/bash -c './tools/strip_type_annotations.sh'

[testenv:bumpversion-dev]
[testenv:bumpversion-to-dev]
basepython=python3
skip_install = true
deps =
bumpversion==0.5.3
commands=
python ./tools/bumpversion-tool.py --dev
python ./tools/bumpversion-tool.py --to-dev {posargs}

[testenv:bumpversion-from-dev]
basepython=python3
skip_install = true
deps =
bumpversion==0.5.3
commands=
python ./tools/bumpversion-tool.py --from-dev {posargs}

[testenv:codemodcheck]
basepython=python3
Expand Down
2 changes: 1 addition & 1 deletion wandb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from __future__ import print_function
from __future__ import unicode_literals

__version__ = "0.10.9.dev1"
__version__ = "0.10.10.dev1"

# Used with pypi checks and other messages related to pip
_wandb_module = "wandb"
Expand Down
73 changes: 56 additions & 17 deletions wandb/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
from wandb import wandb_sdk
from wandb.apis import InternalApi, PublicApi
from wandb.integration.magic import magic_install
from wandb.old.core import wandb_dir

# from wandb.old.core import wandb_dir
from wandb.old.settings import Settings
from wandb.sync import get_run_from_path, get_runs, SyncManager
import yaml
Expand All @@ -41,10 +42,16 @@
whaaaaat = util.vendor_import("whaaaaat")


logging.basicConfig(
filename=os.path.join(wandb_dir(env.get_dir()), "debug-cli.log"),
level=logging.DEBUG,
)
# TODO: turn this on in a cleaner way
# right now we will litter the filesystem with wandb dirs
#
# _wandb_dir = wandb_dir(env.get_dir())
# wandb.wandb_sdk.lib.filesystem._safe_makedirs(_wandb_dir)
# logging.basicConfig(
# filename=os.path.join(_wandb_dir, "debug-cli.log"),
# level=logging.DEBUG,
# )
# logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
logger = logging.getLogger("wandb")

CONTEXT = dict(default_map={})
Expand Down Expand Up @@ -264,25 +271,33 @@ def superagent(project=None, entity=None, agent_spec=None):
# @click.option("--setting", "-s", help="enable an arbitrary setting.", multiple=True)
# @click.option('--show', is_flag=True, help="Show settings")
@click.option("--reset", is_flag=True, help="Reset settings")
@click.option(
"--mode",
"-m",
help=' Can be "online", "offline" or "disabled". Defaults to online.',
)
@click.pass_context
@display_error
def init(ctx, project, entity, reset):
def init(ctx, project, entity, reset, mode):
from wandb.old.core import _set_stage_dir, __stage_dir__, wandb_dir

if __stage_dir__ is None:
_set_stage_dir("wandb")

# non interactive init
if reset or project or entity:
if reset or project or entity or mode:
api = InternalApi()
if reset:
api.clear_setting("entity", persist=True)
api.clear_setting("project", persist=True)
api.clear_setting("mode", persist=True)
# TODO(jhr): clear more settings?
if entity:
api.set_setting("entity", entity, persist=True)
if project:
api.set_setting("project", project, persist=True)
if mode:
api.set_setting("mode", mode, persist=True)
return

if os.path.isdir(wandb_dir()) and os.path.exists(
Expand Down Expand Up @@ -1467,9 +1482,9 @@ def magic_run(cmd, globals, locals):
magic_run(code, globs, None)


@cli.command("on", help="Ensure W&B is enabled in this directory")
@cli.command("online", help="Enable W&B sync")
@display_error
def on():
def online():
api = InternalApi()
try:
api.clear_setting("disabled", persist=True)
Expand All @@ -1480,9 +1495,9 @@ def on():
)


@cli.command("off", help="Disable W&B in this directory, useful for testing")
@cli.command("offline", help="Disable W&B sync")
@display_error
def off():
def offline():
api = InternalApi()
try:
api.set_setting("disabled", "true", persist=True)
Expand All @@ -1495,18 +1510,18 @@ def off():
)


@cli.command("online", hidden=True)
@cli.command("on", hidden=True)
@click.pass_context
@display_error
def online(ctx):
ctx.invoke(on)
def on(ctx):
ctx.invoke(online)


@cli.command("offline", hidden=True)
@cli.command("off", hidden=True)
@click.pass_context
@display_error
def offline(ctx):
ctx.invoke(off)
def off(ctx):
ctx.invoke(offline)


@cli.command("status", help="Show configuration settings")
Expand All @@ -1521,3 +1536,27 @@ def status(settings):
click.echo(
json.dumps(settings, sort_keys=True, indent=2, separators=(",", ": "))
)


@cli.command("disabled", help="Disable W&B.")
def disabled():
api = InternalApi()
try:
api.set_setting("mode", "disabled", persist=True)
click.echo("W&B disabled.")
except configparser.Error:
click.echo(
"Unable to write config, copy and paste the following in your terminal to turn off W&B:\nexport WANDB_MODE=disabled"
)


@cli.command("enabled", help="Enable W&B.")
def enabled():
api = InternalApi()
try:
api.set_setting("mode", "online", persist=True)
click.echo("W&B enabled.")
except configparser.Error:
click.echo(
"Unable to write config, copy and paste the following in your terminal to turn off W&B:\nexport WANDB_MODE=online"
)

0 comments on commit 1477d72

Please sign in to comment.