Skip to content

Commit

Permalink
fix: re-enable and fix rebasing after run step to avoid docker errors…
Browse files Browse the repository at this point in the history
… with results
  • Loading branch information
migraf committed Mar 7, 2023
1 parent 0a6db40 commit 4b79343
Showing 1 changed file with 30 additions and 21 deletions.
51 changes: 30 additions & 21 deletions airflow/dags/DAG_PHT_run_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,28 +283,37 @@ def execute_container(train_state):
print(container_output)
raise ValueError(f"The train execution returned a non zero exit code: {exit_code}")
#
# def _copy(from_cont, from_path, to_cont, to_path):
# """
# Copies a file from one container to another container
# :param from_cont:
# :param from_path:
# :param to_cont:
# :param to_path:
# :return:
# """
# tar_stream, _ = from_cont.get_archive(from_path)
# to_cont.put_archive(os.path.dirname(to_path), tar_stream)
#
# base_image = ':'.join([train_state["repository"], 'base'])
# to_container = client.containers.create(base_image)
# # Copy results to base image
# _copy(from_cont=container,
# from_path="/opt/pht_results",
# to_cont=to_container,
# to_path="/opt/pht_results")

container.commit(repository=train_state["repository"], tag=train_state["tag"])
def _copy(from_cont, from_path, to_cont, to_path):
"""
Copies a file from one container to another container
:param from_cont:
:param from_path:
:param to_cont:
:param to_path:
:return:
"""
tar_stream, _ = from_cont.get_archive(from_path)
to_cont.put_archive(os.path.dirname(to_path), tar_stream)

base_image = ':'.join([train_state["repository"], 'base'])
to_container = client.containers.create(base_image)
# Copy results to base image
_copy(from_cont=container,
from_path="/opt/pht_train",
to_cont=to_container,
to_path="/opt/pht_train")
_copy(from_cont=container,
from_path="/opt/pht_results",
to_cont=to_container,
to_path="/opt/pht_results")
_copy(from_cont=container,
from_path="/opt/train_config.json",
to_cont=to_container,
to_path="/opt/train_config.json")

to_container.commit(repository=train_state["repository"], tag=train_state["tag"])
container.remove(v=True, force=True)
to_container.remove(v=True, force=True)
if exit_code != 0:
raise ValueError(f"The train execution returned a non zero exit code: {exit_code}")

Expand Down

0 comments on commit 4b79343

Please sign in to comment.