This is an automated email from the ASF dual-hosted git repository.

mssun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git


The following commit(s) were added to refs/heads/master by this push:
     new 9af5851  Fix unclosed files in pyscripts (#635)
9af5851 is described below

commit 9af585197d1f3baa5ebe46fd4f0812f1874d3035
Author: Gordon King <[email protected]>
AuthorDate: Thu Mar 17 22:56:57 2022 -0700

    Fix unclosed files in pyscripts (#635)
---
 examples/python/wasm_tvm_mnist_payload/test_lib.py | 7 ++++---
 services/access_control/python/acs_engine_test.py  | 5 +++--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/examples/python/wasm_tvm_mnist_payload/test_lib.py 
b/examples/python/wasm_tvm_mnist_payload/test_lib.py
index 5ff3df5..5586e5b 100755
--- a/examples/python/wasm_tvm_mnist_payload/test_lib.py
+++ b/examples/python/wasm_tvm_mnist_payload/test_lib.py
@@ -30,10 +30,11 @@ loaded_lib = tvm.runtime.load_module(lib_path)
 print(loaded_lib)
 
 dev = tvm.runtime.cpu()
-module = graph_executor.create(open(json_path).read(), loaded_lib, dev)
+with open(json_path) as jsonfile, open(param_path, "rb") as paramfile:
+    module = graph_executor.create(jsonfile.read(), loaded_lib, dev)
 
-loaded_param = bytearray(open(param_path, "rb").read())
-module.load_params(loaded_param)
+    loaded_param = bytearray(paramfile.read())
+    module.load_params(loaded_param)
 
 # Resize it to 28X28
 resized_image = Image.open(img_path).resize((28, 28))
diff --git a/services/access_control/python/acs_engine_test.py 
b/services/access_control/python/acs_engine_test.py
index bf7774e..27aef6a 100644
--- a/services/access_control/python/acs_engine_test.py
+++ b/services/access_control/python/acs_engine_test.py
@@ -21,8 +21,9 @@ if __name__ == '__main__':
     from acs_engine import *
 
     model_path = os.path.join(os.path.dirname(__file__), '../model.conf')
-    test_model = open(model_path).read()
-    acs_setup_model(test_model)
+    with open(model_path) as modelfile:
+        test_model = modelfile.read()
+        acs_setup_model(test_model)
 
     FUSION_TASK               = "data_fusion"
     FUSION_TASK_PARTY_1       = "usr_party1"

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to