def try_check_version(): try: os.makedirs(_ti_core.get_repo_dir(), exist_ok=True) timestamp_path = os.path.join(_ti_core.get_repo_dir(), 'timestamp') cur_date = datetime.date.today() if os.path.exists(timestamp_path): last_time = '' with open(timestamp_path, 'r') as f: last_time = f.readlines()[0].rstrip() if cur_date.strftime('%Y-%m-%d') > last_time: check_version() with open(timestamp_path, 'w') as f: f.write((cur_date + datetime.timedelta(days=7)).strftime('%Y-%m-%d')) f.truncate() else: check_version() with open(timestamp_path, 'w') as f: f.write((cur_date + datetime.timedelta(days=7)).strftime('%Y-%m-%d')) # Wildcard exception to catch potential file writing errors. except Exception as error: print('Checking lastest version failed:', error)
def try_check_version(): try: os.makedirs(_ti_core.get_repo_dir(), exist_ok=True) version_info_path = os.path.join(_ti_core.get_repo_dir(), 'version_info') cur_date = datetime.date.today() if os.path.exists(version_info_path): with open(version_info_path, 'r') as f: version_info_file = f.readlines() last_time = version_info_file[0].rstrip() cur_uuid = version_info_file[2].rstrip() if cur_date.strftime('%Y-%m-%d') > last_time: response = check_version(cur_uuid) write_version_info(response, cur_uuid, version_info_path, cur_date) else: cur_uuid = str(uuid.uuid4()) write_version_info({'status': 0}, cur_uuid, version_info_path, cur_date) response = check_version(cur_uuid) write_version_info(response, cur_uuid, version_info_path, cur_date) # Wildcard exception to catch potential file writing errors. except: pass
def try_check_version(): try: os.makedirs(_ti_core.get_repo_dir(), exist_ok=True) timestamp_path = os.path.join(_ti_core.get_repo_dir(), 'timestamp') cur_date = datetime.date.today() if os.path.exists(timestamp_path): last_time = '' with open(timestamp_path, 'r') as f: last_time = f.readlines()[0].rstrip() if cur_date.strftime('%Y-%m-%d') > last_time: response = check_version() if response is None: return with open(timestamp_path, 'w') as f: f.write((cur_date + datetime.timedelta(days=7)).strftime('%Y-%m-%d')) f.write('\n') if response['status'] == 1: f.write(response['latest_version']) else: f.write('0.0.0') else: response = check_version() if response is None: return with open(timestamp_path, 'w') as f: f.write((cur_date + datetime.timedelta(days=7)).strftime('%Y-%m-%d')) f.write('\n') if response['status'] == 1: f.write(response['latest_version']) else: f.write('0.0.0') # Wildcard exception to catch potential file writing errors. except: pass
def _get_benchmark_output_dir(): return os.path.join(_ti_core.get_repo_dir(), 'benchmarks', 'output')
def _get_benchmark_baseline_dir(): return os.path.join(_ti_core.get_repo_dir(), 'benchmarks', 'baseline')
def benchmark_plot(fn=None, cases=None, columns=None, column_titles=None, archs=None, title=None, bars='sync_vs_async', bar_width=0.4, bar_distance=0, left_margin=0, size=(12, 8)): import matplotlib.pyplot as plt # pylint: disable=C0415 import yaml # pylint: disable=C0415 if fn is None: fn = os.path.join(_ti_core.get_repo_dir(), 'benchmarks', 'output', 'benchmark.yml') with open(fn, 'r') as f: data = yaml.load(f, Loader=yaml.SafeLoader) if bars != 'sync_vs_async': # need baseline baseline_dir = os.path.join(_ti_core.get_repo_dir(), 'benchmarks', 'baseline') baseline_file = f'{baseline_dir}/benchmark.yml' with open(baseline_file, 'r') as f: baseline_data = yaml.load(f, Loader=yaml.SafeLoader) if cases is None: cases = list(data.keys()) assert len(cases) >= 1 if len(cases) == 1: cases = [cases[0], cases[0]] ti.warning( 'Function benchmark_plot does not support plotting with only one case for now. Duplicating the item to move on.' ) if columns is None: columns = list(data[cases[0]].keys()) if column_titles is None: column_titles = columns normalize_to_lowest = lambda x: True figure, subfigures = plt.subplots(len(cases), len(columns)) if title is None: title = 'Taichi Performance Benchmarks (Higher means more)' figure.suptitle(title, fontweight="bold") for col_id in range(len(columns)): subfigures[0][col_id].set_title(column_titles[col_id]) for case_id, case in enumerate(cases): subfigures[case_id][0].annotate( case, xy=(0, 0.5), xytext=(-subfigures[case_id][0].yaxis.labelpad - 5, 0), xycoords=subfigures[case_id][0].yaxis.label, textcoords='offset points', size='large', ha='right', va='center') for col_id, col in enumerate(columns): if archs is None: current_archs = data[case][col].keys() else: current_archs = [ x for x in archs if x in data[case][col].keys() ] if bars == 'sync_vs_async': y_left = [ data[case][col][arch]['sync'] for arch in current_archs ] label_left = 'sync' y_right = [ data[case][col][arch]['async'] for arch in current_archs ]