Skip to content

Commit

Permalink
Merge pull request #85 from sightmachine/ENG-6332
Browse files Browse the repository at this point in the history
Eng-6332: SMSDK bug for EFMW Arolsen - cli.get_machine_type_names() hits an error
  • Loading branch information
siddharthvelotio authored Sep 18, 2024
2 parents bbe77d6 + 6b1166a commit 2f79afa
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
2 changes: 2 additions & 0 deletions smsdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def dict_to_df(data, normalize=True):
# machine type stats are list
cols = [*data[0]]
cols.remove("stats")
if "part_types" in cols:
cols.remove("part_types")
df = json_normalize(
data, "stats", cols, record_prefix="stats.", errors="ignore"
)
Expand Down
2 changes: 2 additions & 0 deletions smsdk/client_v0.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def dict_to_df(data, normalize=True):
# machine type stats are list
cols = [*data[0]]
cols.remove("stats")
if "part_types" in cols:
cols.remove("part_types")
df = json_normalize(data, "stats", cols, record_prefix="stats.")
else:
try:
Expand Down
12 changes: 6 additions & 6 deletions tests/Uri/test_uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_create_client_using_uri() -> None:
assert cli.tenant == "demo-sdk-test", "Tenant should be initialized correctly"
assert cli.config["protocol"] == "https", "Protocol should be set to HTTPS"
assert (
cli.config["site.domain"] == "localnet"
cli.config["site.domain"] == "localnet.sightmachine.io"
), "Site domain should be set to localnet"

tenant = "https://demo-sdk-test.localnet"
Expand All @@ -71,7 +71,7 @@ def test_create_client_using_uri() -> None:
assert cli.tenant == "demo-sdk-test", "Tenant should be initialized correctly"
assert cli.config["protocol"] == "https", "Protocol should be set to HTTPS"
assert (
cli.config["site.domain"] == "localnet"
cli.config["site.domain"] == "localnet.sightmachine.io"
), "Site domain should be set to localnet"

tenant = "http://demo-sdk-test.localnet:8080/"
Expand All @@ -80,7 +80,7 @@ def test_create_client_using_uri() -> None:
assert cli.tenant == "demo-sdk-test", "Tenant should be initialized correctly"
assert cli.config["protocol"] == "http", "Protocol should be set to HTTP"
assert (
cli.config["site.domain"] == "localnet"
cli.config["site.domain"] == "localnet.sightmachine.io"
), "Site domain should be set to localnet"


Expand All @@ -91,7 +91,7 @@ def test_create_client_uri_special_cases() -> None:
assert cli.tenant == "demo-sdk-test", "Tenant should be initialized correctly"
assert cli.config["protocol"] == "https", "Protocol should be set to HTTPS"
assert (
cli.config["site.domain"] == "localnet"
cli.config["site.domain"] == "localnet.sightmachine.io"
), "Site domain should be set to localnet"

tenant = "http://demo-sdk-test"
Expand All @@ -109,7 +109,7 @@ def test_create_client_uri_special_cases() -> None:
assert cli.tenant == "demo-sdk-test", "Tenant should be initialized correctly"
assert cli.config["protocol"] == "https", "Protocol should be set to HTTPS"
assert (
cli.config["site.domain"] == "localnet"
cli.config["site.domain"] == "localnet.sightmachine.io"
), "Site domain should be set to localnet"

tenant = "://demo-sdk-test.localnet:8080"
Expand All @@ -118,5 +118,5 @@ def test_create_client_uri_special_cases() -> None:
assert cli.tenant == "demo-sdk-test", "Tenant should be initialized correctly"
assert cli.config["protocol"] == "https", "Protocol should be set to HTTPS"
assert (
cli.config["site.domain"] == "localnet"
cli.config["site.domain"] == "localnet.sightmachine.io"
), "Site domain should be set to localnet"
8 changes: 4 additions & 4 deletions tests/machine/test_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,21 +235,21 @@ def test_get_machine_schema(get_client):

# Run
df = get_client.get_machine_schema(machine)
assert df.shape == (35, 13)
assert df.shape == (36, 15)

# Run
df = get_client.get_machine_schema(machine, types)
assert df.shape == (16, 13)
assert df.shape == (16, 14)

query = {"machine_source": machine, "types": types}

# Run
df = get_client.get_machine_schema(**query)
assert df.shape == (16, 13)
assert df.shape == (16, 14)

query = {"machine_source": machine, "types": types, "return_mtype": True}

# Run
df = get_client.get_machine_schema(**query)
assert df[1].shape == (16, 13)
assert df[1].shape == (16, 14)
assert df[0] == LASERCUT_MACHINE_TYPE
2 changes: 1 addition & 1 deletion tests/machine_type/test_machine_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def test_get_fields_of_machine_type(get_client):

# Run
fields = get_client.get_fields_of_machine_type(machine_type)
assert len(fields) == 35
assert len(fields) == 36

# Run
fields = get_client.get_fields_of_machine_type(machine_type, types)
Expand Down

0 comments on commit 2f79afa

Please sign in to comment.