Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lang] Add time check before performing version check #3589

Merged
merged 4 commits into from Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion python/taichi/core/util.py
Expand Up @@ -110,7 +110,6 @@ def get_unique_task_id():
ti_core = import_ti_core()

ti_core.set_python_package_dir(package_root())
os.makedirs(ti_core.get_repo_dir(), exist_ok=True)

log_level = os.environ.get('TI_LOG_LEVEL', '')
if log_level:
Expand Down
21 changes: 20 additions & 1 deletion python/taichi/main.py
@@ -1,4 +1,5 @@
import argparse
import datetime
import math
import os
import platform
Expand Down Expand Up @@ -69,7 +70,25 @@ def __init__(self, test_mode: bool = False):

self.main_parser = parser

self._check_version()
# Check timestamp
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:
with open(timestamp_path, 'w') as f:
f.write((cur_date +
datetime.timedelta(days=14)).strftime('%Y-%m-%d'))
f.truncate()
self._check_version()
else:
with open(timestamp_path, 'w') as f:
f.write((cur_date +
datetime.timedelta(days=14)).strftime('%Y-%m-%d'))
self._check_version()

@timer
def __call__(self):
Expand Down