Skip to content

Commit

Permalink
Merge branch 'master' into tim/code-quality/flake-data-types
Browse files Browse the repository at this point in the history
  • Loading branch information
raubitsj committed Jan 9, 2021
2 parents 0dfc494 + ec99dfe commit 551b624
Show file tree
Hide file tree
Showing 43 changed files with 3,010 additions and 431 deletions.
23 changes: 18 additions & 5 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,25 @@ ignore_errors = True

[mypy-wandb.sdk.*]
ignore_errors = False
strict_equality = True
implicit_reexport = False

[mypy-wandb.internal.*]
ignore_errors = False
# Turn these on eventually
# disallow_untyped_defs = True
# disallow_untyped_calls = True

[mypy-wandb.backend.*]
ignore_errors = False
[mypy-wandb.sdk.wandb_run]
disallow_incomplete_defs = True

# Find some errors
# check_untyped_defs = True

[mypy-wandb.interface.*]
[mypy-wandb.sdk.lib.telemetry]
disallow_untyped_defs = True
disallow_untyped_calls = True

[mypy-wandb.proto.*]
ignore_errors = False

[mypy-wandb.proto.wandb_server_pb2_grpc]
ignore_errors = True
4 changes: 3 additions & 1 deletion standalone_tests/point_cloud_scene.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os
import numpy as np
import wandb

wandb.init(project="lidar-scene-test")
os.environ.setdefault("WANDB_PROJECT", "lidar-scene-test")
wandb.init()


N_POINT = 1000
Expand Down
21 changes: 21 additions & 0 deletions tests/wandb_artifacts_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import shutil
import wandb.data_types as data_types
import numpy as np
import pandas as pd


def mock_boto(artifact, path=False):
Expand Down Expand Up @@ -409,6 +410,26 @@ def test_add_reference_unknown_handler(runner):
}


def test_add_table_from_dataframe(live_mock_server, test_settings):
df_float = pd.DataFrame([[1, 2.0, 3.0]], dtype=np.float)
df_float32 = pd.DataFrame([[1, 2.0, 3.0]], dtype=np.float32)
df_bool = pd.DataFrame([[True, False, True]], dtype=np.bool)

wb_table_float = wandb.Table(dataframe=df_float)
wb_table_float32 = wandb.Table(dataframe=df_float32)
wb_table_float32_recast = wandb.Table(dataframe=df_float32.astype(np.float))
wb_table_bool = wandb.Table(dataframe=df_bool)

run = wandb.init(settings=test_settings)
artifact = wandb.Artifact("table-example", "dataset")
artifact.add(wb_table_float, "wb_table_float")
artifact.add(wb_table_float32_recast, "wb_table_float32_recast")
artifact.add(wb_table_float32, "wb_table_float32")
artifact.add(wb_table_bool, "wb_table_bool")
run.log_artifact(artifact)
run.finish()


def test_add_obj_wbimage_no_classes(runner):
test_folder = os.path.dirname(os.path.realpath(__file__))
im_path = os.path.join(test_folder, "..", "assets", "2x2.png")
Expand Down
2 changes: 1 addition & 1 deletion tests/wandb_config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from wandb import wandb_sdk


def callback_func(key, val, data):
def callback_func(key=None, val=None, data=None):
print(key, val, data)


Expand Down
18 changes: 12 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ skip_install = true
deps =
grpcio==1.27.2
grpcio-tools==1.27.2
mypy-protobuf
changedir={toxinidir}/wandb/proto
commands=
python wandb_internal_codegen.py
Expand All @@ -95,7 +96,7 @@ deps =
flake8-fixme
flake8-typing-imports>=1.1
flake8-import-order>=0.9
# flake8-docstrings>=1.3.1
flake8-docstrings>=1.3.1
commands =
flake8

Expand Down Expand Up @@ -163,11 +164,15 @@ ignore =
E203,
# select = C,E,F,W,B,B901,I,N
per-file-ignores =
wandb/cli/cli.py:E501,C901,I202,E203 # conflict with black
wandb/sdk/wandb_watch.py:E501
wandb/lib/git.py:E501
wandb/wandb_controller.py:N803,N806
wandb/apis/public.py:B006
tools/*:D
wandb/*:D
wandb/cli/cli.py:E501,C901,I202,E203,D # conflict with black
wandb/sdk/wandb_watch.py:E501,D
wandb/lib/git.py:E501,D
wandb/wandb_controller.py:N803,N806,D
wandb/apis/public.py:B006,D
wandb/sdk/wandb_run.py:D1,D2,D3,D4
wandb/sdk/wandb_init.py:D1,D2,D3,D4
exclude =
.tox,
.git,
Expand Down Expand Up @@ -219,6 +224,7 @@ max-complexity = 18
import-order-style = google
application-import-names = flake8
format = ${cyan}%(path)s${reset}:${yellow_bold}%(row)d${reset}:${green_bold}%(col)d${reset}: ${red_bold}%(code)s${reset} %(text)s
docstring-convention = google

[testenv:covercircle]
skip_install = true
Expand Down
2 changes: 1 addition & 1 deletion wandb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
from wandb.errors.term import termsetup, termlog, termerror, termwarn

PY3 = sys.version_info.major == 3 and sys.version_info.minor >= 6
TYPE_CHECKING = False # type: bool
if PY3:
TYPE_CHECKING = True
from wandb import sdk as wandb_sdk
else:
TYPE_CHECKING = False
from wandb import sdk_py27 as wandb_sdk

import wandb
Expand Down
7 changes: 4 additions & 3 deletions wandb/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,19 +242,20 @@ def login(key, host, cloud, relogin, anonymously, no_offline=False):
@cli.command(
context_settings=CONTEXT, help="Run a grpc server", name="grpc-server", hidden=True
)
@click.option("--port", default=None, help="The host port to bind grpc service.")
@display_error
def grpc_server(project=None, entity=None):
def grpc_server(project=None, entity=None, port=None):
_ = util.get_module(
"grpc",
required="grpc-server requires the grpcio library, run pip install wandb[grpc]",
)
from wandb.server.grpc_server import main as grpc_server

grpc_server()
grpc_server(port=port)


@cli.command(context_settings=CONTEXT, help="Run a SUPER agent", hidden=True)
@click.option("--project", "-p", default=None, help="The project use.")
@click.option("--project", "-p", default=None, help="The project to use.")
@click.option("--entity", "-e", default=None, help="The entity to use.")
@click.argument("agent_spec", nargs=-1)
@display_error
Expand Down
4 changes: 2 additions & 2 deletions wandb/data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ def to_json(self, run_or_artifact):

elif isinstance(run_or_artifact, wandb_artifacts.Artifact):
for column in self.columns:
if "." in column:
if isinstance(column, six.string_types) and "." in column:
raise ValueError(
"invalid column name: {} - tables added to artifacts must not contain periods.".format(
column
Expand All @@ -728,7 +728,7 @@ def json_helper(val):
res[key] = json_helper(val[key])
return res
else:
return val
return util.json_friendly(val)[0]

for row in data:
mapped_row = []
Expand Down
58 changes: 43 additions & 15 deletions wandb/proto/wandb_internal.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ syntax = "proto3";
package wandb_internal;

import "google/protobuf/timestamp.proto";
import "wandb/proto/wandb_telemetry.proto";

/*
* Record: Persistent on disk data (BE CAREFUL)
Expand All @@ -23,23 +24,24 @@ message Record {
int64 num = 1;
oneof record_type {
// Low numbers for more frequent data
HistoryRecord history = 2;
SummaryRecord summary = 3;
OutputRecord output = 4;
ConfigRecord config = 5;
FilesRecord files = 6;
StatsRecord stats = 7;
ArtifactRecord artifact = 8;
TBRecord tbrecord = 9;
AlertRecord alert = 10;
HistoryRecord history = 2;
SummaryRecord summary = 3;
OutputRecord output = 4;
ConfigRecord config = 5;
FilesRecord files = 6;
StatsRecord stats = 7;
ArtifactRecord artifact = 8;
TBRecord tbrecord = 9;
AlertRecord alert = 10;
TelemetryRecord telemetry = 11;
// Higher numbers for less frequent data
RunRecord run = 17;
RunExitRecord exit = 18;
FinalRecord final = 20;
HeaderRecord header = 21;
FooterRecord footer = 22;
RunRecord run = 17;
RunExitRecord exit = 18;
FinalRecord final = 20;
HeaderRecord header = 21;
FooterRecord footer = 22;
// request field does not belong here longterm
Request request = 100;
Request request = 100;
}
Control control = 16;
string uuid = 19;
Expand Down Expand Up @@ -107,6 +109,7 @@ message RunRecord {
string storage_id = 16;
google.protobuf.Timestamp start_time = 17;
bool resumed = 18;
TelemetryRecord telemetry = 19;
}

message RunUpdateResult {
Expand Down Expand Up @@ -334,6 +337,7 @@ message Request {
RunStartRequest run_start = 11;
CheckVersionRequest check_version = 12;
ShutdownRequest shutdown = 64;
TestInjectRequest test_inject = 1000;
}
}

Expand All @@ -350,6 +354,7 @@ message Response {
RunStartResponse run_start_response = 28;
CheckVersionResponse check_version_response = 29;
ShutdownResponse shutdown_response = 64;
TestInjectResponse test_inject_response = 1000;
}
}

Expand Down Expand Up @@ -450,6 +455,29 @@ message ShutdownRequest {
message ShutdownResponse {
}

/*
* TestInjectRequest:
*/
message TestInjectRequest {
bool handler_exc = 1;
bool handler_exit = 2;
bool handler_abort = 3;
bool sender_exc = 4;
bool sender_exit = 5;
bool sender_abort = 6;
bool req_exc = 7;
bool req_exit = 8;
bool req_abort = 9;
bool resp_exc = 10;
bool resp_exit = 11;
bool resp_abort = 12;
bool msg_drop = 13;
bool msg_hang = 14;
}

message TestInjectResponse {
}

/*
* SampledHistoryRequest:
*/
Expand Down
13 changes: 12 additions & 1 deletion wandb/proto/wandb_internal_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import subprocess

import grpc_tools
import grpc_tools # type: ignore
from grpc_tools import protoc # type: ignore


Expand Down Expand Up @@ -36,14 +36,25 @@ def get_requirements_version(requirements_file, package):
'-I', proto_root,
'-I', '.',
'--python_out=.',
'--mypy_out=.',
'wandb/proto/wandb_internal.proto',
))

protoc.main((
'',
'-I', proto_root,
'-I', '.',
'--python_out=.',
'--mypy_out=.',
'wandb/proto/wandb_telemetry.proto',
))

protoc.main((
'',
'-I', proto_root,
'-I', '.',
'--python_out=.',
'--grpc_python_out=.',
'--mypy_out=.',
'wandb/proto/wandb_server.proto',
))

0 comments on commit 551b624

Please sign in to comment.