Skip to content

Commit

Permalink
fix no config bug. fix \r print statements (hopefully)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kory Stiger committed Jul 14, 2021
1 parent 846b64c commit df1202e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions test/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def test_2(**init_kwargs):
def test_3(**init_kwargs):
""""""
zpy.init(**init_kwargs)
dataset_config = zpy.DatasetConfig("can_v7")
dataset_config = zpy.DatasetConfig("dumpster_v2")
# dataset_config.set("run\\.padding_style", "square")
zpy.generate("can_v7.4", dataset_config, num_datapoints=10, materialize=True)
zpy.generate("dumpster_v2.16", dataset_config, num_datapoints=8, materialize=True)


if __name__ == "__main__":
Expand All @@ -52,7 +52,7 @@ def test_3(**init_kwargs):
# }
# print("Running test_1:")
# test_1(**init_kwargs)
print("Running test_2:")
test_2(**init_kwargs)
# print("Running test_3:")
# test_3(**init_kwargs)
# print("Running test_2:")
# test_2(**init_kwargs)
print("Running test_3:")
test_3(**init_kwargs)
16 changes: 8 additions & 8 deletions zpy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Dict, Union

import requests
from pydash import set_, unset
from pydash import set_, unset, is_empty

from cli.utils import download_url
from zpy.client_util import (
Expand Down Expand Up @@ -71,7 +71,7 @@ def __init__(self, sim_name: str, **kwargs):
sim_name: Name of Sim
"""
self._sim = None
self._config = None
self._config = {}

unique_sim_filters = {
"project": _project["id"],
Expand Down Expand Up @@ -114,8 +114,6 @@ def set(self, path: str, value: any):
path: The json gin config path. Ex. given object { a: b: [{ c: 1 }]}, the value at path "a.b[0]c" is 1.
value: The value for the gin config path provided.
"""
if self._config is None:
self._config = {}
set_(self._config, path, value)

def unset(self, path):
Expand All @@ -142,7 +140,7 @@ def preview(dataset_config: DatasetConfig, num_samples=10):

config_filters = (
{}
if dataset_config.config is None
if is_empty(dataset_config.config)
else {"config": to_query_param_value(dataset_config.config)}
)
filter_params = {
Expand Down Expand Up @@ -223,6 +221,7 @@ def generate(
)

if materialize:
print("Materialize requested, waiting until dataset finishes to download it.")
dataset = get(
f"{_base_url}/api/v1/datasets/{dataset['id']}/",
headers=auth_header(_auth_token),
Expand All @@ -231,13 +230,14 @@ def generate(
next_check_datetime = datetime.now() + timedelta(seconds=60)
while datetime.now() < next_check_datetime:
print(
f"Dataset is not ready. Checking again in {(next_check_datetime - datetime.now()).seconds}s.",
end="\r",
"\r{}".format(
f"Dataset is not ready. Checking again in {(next_check_datetime - datetime.now()).seconds}s."),
end="",
)
time.sleep(1)

clear_last_print()
print("Checking dataset...", end="\r")
print("\r{}".format("Checking dataset...", end=""))
dataset = get(
f"{_base_url}/api/v1/datasets/{dataset['id']}/",
headers=auth_header(_auth_token),
Expand Down

0 comments on commit df1202e

Please sign in to comment.