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

fix deployment issue in multi envs #49

Merged
merged 1 commit into from
Sep 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 24 additions & 15 deletions maro/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,30 @@ def deploy(hide_info=True):
error_list = []
try:
clean_deployment_folder()
for target_dir, source_dir in target_source_pairs:
shutil.copytree(source_dir, target_dir)
# deploy success
# deploy started
version_info = configparser.ConfigParser()
version_info["MARO_DATA"] = {}
version_info["MARO_DATA"]["version"] = __data_version__
version_info["MARO_DATA"]["deploy_time"] = str(int(time.time()))
version_info["MARO_DATA"]["deploy_status"] = "started"
with io.open(version_file_path, "w") as version_file:
version_info.write(version_file)

for target_dir, source_dir in target_source_pairs:
shutil.copytree(source_dir, target_dir)
# deploy success
version_info["MARO_DATA"]["deploy_status"] = "deployed"
with io.open(version_file_path, "w") as version_file:
version_info.write(version_file)
info_list.append("Data files for MARO deployed.")
except Exception as e:
# deploy success
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deploy failed

error_list.append(f"An issue occured while deploying meta files for MARO. {e} Please run 'maro meta deploy' to deploy the data files.")

for target_dir, _ in target_source_pairs:
if os.path.exists(target_dir):
shutil.rmtree(target_dir)
version_info["MARO_DATA"]["deploy_status"] = "failed"
with io.open(version_file_path, "w") as version_file:
version_info.write(version_file)
clean_deployment_folder()

finally:
if len(error_list) > 0:
for error in error_list:
Expand All @@ -110,14 +118,15 @@ def deploy(hide_info=True):
def check_deployment_status():
ret = False
if os.path.exists(version_file_path):
with io.open(version_file_path, "r") as version_file:
version_info = configparser.ConfigParser()
version_info.read(version_file)
if "MARO_DATA" in version_info \
and "deploy_time" in version_info["MARO_DATA"] \
and "version" in version_info["MARO_DATA"] \
and version_info["MARO_DATA"]["version"] == __data_version__:
ret = True
version_info = configparser.ConfigParser()
version_info.read(version_file_path)
if "MARO_DATA" in version_info \
and "deploy_time" in version_info["MARO_DATA"] \
and "version" in version_info["MARO_DATA"] \
and "deploy_status" in version_info["MARO_DATA"] \
and version_info["MARO_DATA"]["version"] == __data_version__ \
and version_info["MARO_DATA"]["deploy_status"] != "failed" :
ret = True
return ret


Expand Down