Browse Source

!60 use unique file name during json data generation

From: @dabaiji
Reviewed-by: @anyrenwei,@dylangeng
Signed-off-by: @dylangeng
pull/60/MERGE
mindspore-ci-bot Gitee 5 years ago
parent
commit
df73b09ebc
1 changed files with 12 additions and 3 deletions
  1. +12
    -3
      tests/common/gen_json_data.py

+ 12
- 3
tests/common/gen_json_data.py View File

@@ -17,6 +17,7 @@ import json
import logging
import inspect
import numpy as np
import subprocess
from tests.common.gen_random import random_gaussian


@@ -365,7 +366,15 @@ def gen_json_data(op_desc):
output_indexes = []
expect = []

p = CodePrinter('json_data.py')
op_name = desc.get("op")
if len(op_name.split("_")) > 0:
op_hash = op_name.split("_")[-1]
else:
import time
op_hash = str(time.time())

uni_file_name = "json_data_" + op_hash + ".py"
p = CodePrinter(uni_file_name)
idx = 0

# Collect input which should be processed by atomic clean.
@@ -495,8 +504,8 @@ def gen_json_data(op_desc):

p.close()

with open("json_data.py", 'r') as f:
with open(uni_file_name, 'r') as f:
sent = f.read()
exec(sent)
subprocess.run("rm %s" % uni_file_name, shell=True)
return input_for_mod, expect, output_indexes

Loading…
Cancel
Save