Browse Source

[MNT] solve F541 error of flake8 in package

tags/v0.3.2
Gene 1 year ago
parent
commit
aeb24a7d11
3 changed files with 16 additions and 16 deletions
  1. +1
    -1
      tests/test_learnware_client/test_upload.py
  2. +11
    -11
      tests/test_workflow/test_hetero_workflow.py
  3. +4
    -4
      tests/test_workflow/test_workflow.py

+ 1
- 1
tests/test_learnware_client/test_upload.py View File

@@ -60,7 +60,7 @@ class TestUpload(unittest.TestCase):

download_learnware_id = "00000084"
with tempfile.TemporaryDirectory(prefix="learnware_") as tempdir:
zip_path = os.path.join(tempdir, f"test.zip")
zip_path = os.path.join(tempdir, "test.zip")
self.client.download_learnware(download_learnware_id, zip_path)
learnware_id = self.client.upload_learnware(
learnware_zip_path=zip_path, semantic_specification=semantic_spec


+ 11
- 11
tests/test_workflow/test_hetero_workflow.py View File

@@ -81,7 +81,7 @@ class TestHeteroWorkflow(unittest.TestCase):
self.learnware_num = learnware_num

print("Total Item:", len(hetero_market))
assert len(hetero_market) == 0, f"The market should be empty!"
assert len(hetero_market) == 0, "The market should be empty!"

for idx, zip_path in enumerate(self.zip_path_list):
semantic_spec = generate_semantic_spec(
@@ -109,7 +109,7 @@ class TestHeteroWorkflow(unittest.TestCase):

curr_inds = hetero_market.get_learnware_ids()
print("Available ids After Deleting Learnwares:", curr_inds)
assert len(curr_inds) == 0, f"The market should be empty!"
assert len(curr_inds) == 0, "The market should be empty!"

return hetero_market

@@ -140,20 +140,20 @@ class TestHeteroWorkflow(unittest.TestCase):
search_result = hetero_market.search_learnware(user_info)
single_result = search_result.get_single_results()

print(f"Search result1:")
assert len(single_result) == 1, f"Exact semantic search failed!"
print("Search result1:")
assert len(single_result) == 1, "Exact semantic search failed!"
for search_item in single_result:
semantic_spec1 = search_item.learnware.get_specification().get_semantic_spec()
print("Choose learnware:", search_item.learnware.id)
assert semantic_spec1["Name"]["Values"] == semantic_spec["Name"]["Values"], f"Exact semantic search failed!"
assert semantic_spec1["Name"]["Values"] == semantic_spec["Name"]["Values"], "Exact semantic search failed!"

semantic_spec["Name"]["Values"] = "laernwaer"
user_info = BaseUserInfo(semantic_spec=semantic_spec)
search_result = hetero_market.search_learnware(user_info)
single_result = search_result.get_single_results()

print(f"Search result2:")
assert len(single_result) == self.learnware_num, f"Fuzzy semantic search failed!"
print("Search result2:")
assert len(single_result) == self.learnware_num, "Fuzzy semantic search failed!"
for search_item in single_result:
print("Choose learnware:", search_item.learnware.id)

@@ -208,7 +208,7 @@ class TestHeteroWorkflow(unittest.TestCase):
search_result = hetero_market.search_learnware(user_info)
single_result = search_result.get_single_results()

assert len(single_result) == 0, f"Statistical search failed!"
assert len(single_result) == 0, "Statistical search failed!"

# delete key "Task" in semantic_spec, use homo search and print WARNING INFO with "User doesn't provide correct task type"
print(">> delele key 'Task' test:")
@@ -217,7 +217,7 @@ class TestHeteroWorkflow(unittest.TestCase):
search_result = hetero_market.search_learnware(user_info)
single_result = search_result.get_single_results()

assert len(single_result) == 0, f"Statistical search failed!"
assert len(single_result) == 0, "Statistical search failed!"

# modify semantic info with mismatch dim, use homo search and print "User data feature dimensions mismatch with semantic specification."
print(">> mismatch dim test")
@@ -235,7 +235,7 @@ class TestHeteroWorkflow(unittest.TestCase):
search_result = hetero_market.search_learnware(user_info)
single_result = search_result.get_single_results()

assert len(single_result) == 0, f"Statistical search failed!"
assert len(single_result) == 0, "Statistical search failed!"

def test_homo_stat_search(self, learnware_num=5):
hetero_market = self.test_train_market_model(learnware_num, delete=False)
@@ -254,7 +254,7 @@ class TestHeteroWorkflow(unittest.TestCase):
single_result = search_result.get_single_results()
multiple_result = search_result.get_multiple_results()

assert len(single_result) >= 1, f"Statistical search failed!"
assert len(single_result) >= 1, "Statistical search failed!"
print(f"search result of user{idx}:")
for single_item in single_result:
print(f"score: {single_item.score}, learnware_id: {single_item.learnware.id}")


+ 4
- 4
tests/test_workflow/test_workflow.py View File

@@ -74,7 +74,7 @@ class TestWorkflow(unittest.TestCase):
self.learnware_num = learnware_num

print("Total Item:", len(easy_market))
assert len(easy_market) == 0, f"The market should be empty!"
assert len(easy_market) == 0, "The market should be empty!"

for idx, zip_path in enumerate(self.zip_path_list):
semantic_spec = generate_semantic_spec(
@@ -109,7 +109,7 @@ class TestWorkflow(unittest.TestCase):

curr_inds = easy_market.get_learnware_ids()
print("Available ids After Deleting Learnwares:", curr_inds)
assert len(curr_inds) == 0, f"The market should be empty!"
assert len(curr_inds) == 0, "The market should be empty!"

return easy_market

@@ -132,7 +132,7 @@ class TestWorkflow(unittest.TestCase):
search_result = easy_market.search_learnware(user_info)
single_result = search_result.get_single_results()

print(f"Search result:")
print("Search result:")
for search_item in single_result:
print("Choose learnware:", search_item.learnware.id)

@@ -154,7 +154,7 @@ class TestWorkflow(unittest.TestCase):
single_result = search_results.get_single_results()
multiple_result = search_results.get_multiple_results()

assert len(single_result) >= 1, f"Statistical search failed!"
assert len(single_result) >= 1, "Statistical search failed!"
print(f"search result of user{idx}:")
for search_item in single_result:
print(f"score: {search_item.score}, learnware_id: {search_item.learnware.id}")


Loading…
Cancel
Save