Skip to content
This repository has been archived by the owner on Aug 25, 2024. It is now read-only.

Commit

Permalink
df: kubernetes: output server: Provide own file contents as variable
Browse files Browse the repository at this point in the history
Also move execute from JSON code

Signed-off-by: John Andersen <johnandersenpdx@gmail.com>
  • Loading branch information
pdxjohnny committed Jul 29, 2022
1 parent 436d6be commit c89d3d8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
13 changes: 3 additions & 10 deletions dffml/df/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,7 @@
Subprocess,
)
from ..util.internal import load_dataflow_from_configloader

# TODO Use importlib.resources instead of reading via pathlib
python_code: str = pathlib.Path(__file__).parent.joinpath(
"kubernetes_execute_pickled_dataflow_with_inputs.py"
).read_text()
output_server: str = pathlib.Path(__file__).parent.joinpath(
"kubernetes_output_server.py"
).read_text()
from .kubernetes_output_server import PYTHON_CODE, OUTPUT_SERVER


class JobKubernetesOrchestratorPreApplyDefinitions(enum.Enum):
Expand Down Expand Up @@ -278,12 +271,12 @@ async def run_operations_for_ctx(
execute_pickled_dataflow_with_inputs_path = tempdir_path.joinpath(
"execute_pickled_dataflow_with_inputs.py"
)
execute_pickled_dataflow_with_inputs_path.write_text(python_code)
execute_pickled_dataflow_with_inputs_path.write_text(PYTHON_CODE)
# Write out the Python code to execute the dataflow
kubernetes_output_server_path = tempdir_path.joinpath(
"kubernetes_output_server.py"
)
kubernetes_output_server_path.write_text(output_server)
kubernetes_output_server_path.write_text(OUTPUT_SERVER)
# Write out the prerun dataflow (secret)
prerun_dataflow_path = tempdir_path.joinpath(
"prerun-dataflow.json"
Expand Down
6 changes: 6 additions & 0 deletions dffml/df/kubernetes_output_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@

LOGGER = logging.getLogger(pathlib.Path(__file__).stem)

# TODO Use importlib.resources instead of reading via pathlib
PYTHON_CODE: str = pathlib.Path(__file__).parent.joinpath(
"kubernetes_execute_pickled_dataflow_with_inputs.py"
).read_text()
OUTPUT_SERVER: str = pathlib.Path(__file__).read_text()


async def concurrently(
work: Dict[asyncio.Task, Any],
Expand Down
14 changes: 3 additions & 11 deletions dffml/df/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
MemoryRedundancyChecker,
MEMORYORCHESTRATORCONFIG_MAX_CTXS,
)
from .kubernetes_output_server import server_socket_unix_stream, read_messages
from .kubernetes_output_server import server_socket_unix_stream, read_messages, PYTHON_CODE, OUTPUT_SERVER
from ..operation.output import GetSingle, get_single_spec
from ..base import config, field
from ..util.crypto import secure_hash
Expand All @@ -98,14 +98,6 @@
)
from ..util.internal import load_dataflow_from_configloader

# TODO Use importlib.resources instead of reading via pathlib
python_code: str = pathlib.Path(__file__).parent.joinpath(
"kubernetes_execute_pickled_dataflow_with_inputs.py"
).read_text()
output_server: str = pathlib.Path(__file__).parent.joinpath(
"kubernetes_output_server.py"
).read_text()


@config
class SSHOrchestratorConfig:
Expand Down Expand Up @@ -300,13 +292,13 @@ async def run_operations_for_ctx(
"execute_pickled_dataflow_with_inputs.py"
)
execute_pickled_dataflow_with_inputs_path.write_text(
python_code
PYTHON_CODE
)
# Write out the Python code to execute the dataflow
kubernetes_output_server_path = tempdir_path.joinpath(
"kubernetes_output_server.py"
)
kubernetes_output_server_path.write_text(output_server)
kubernetes_output_server_path.write_text(OUTPUT_SERVER)
# Write out the prerun dataflow
prerun_dataflow_path = tempdir_path.joinpath(
"prerun-dataflow.json"
Expand Down

0 comments on commit c89d3d8

Please sign in to comment.