Skip to content

Commit 6f06ad8

Browse files
committed
Fixed formatting issues and added unit test
Signed-off-by: Atharva <atharvakulkarni172003@gmail.com>
1 parent d4fa04a commit 6f06ad8

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

flytekit/bin/entrypoint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,9 @@ def setup_execution(
470470
if checkpoint_path is not None:
471471
checkpointer = SyncCheckpoint(checkpoint_dest=checkpoint_path, checkpoint_src=prev_checkpoint)
472472
logger.debug(f"Checkpointer created with source {prev_checkpoint} and dest {checkpoint_path}")
473-
473+
474474
node_index = _compute_array_job_index()
475-
475+
476476
execution_parameters = ExecutionParameters(
477477
execution_id=_identifier.WorkflowExecutionIdentifier(
478478
project=exe_project,

tests/flytekit/unit/bin/test_python_entrypoint.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from flytekit.models import literals as _literal_models
3838
from flytekit.models.core import errors as error_models, execution
3939
from flytekit.models.core import execution as execution_models
40+
from flytekit.bin.entrypoint import _compute_array_job_index
4041
from flytekit.core.utils import write_proto_to_file
4142
from flytekit.models.types import LiteralType, SimpleType
4243

@@ -406,6 +407,16 @@ def test_dispatch_execute_system_error(mock_write_to_file, mock_upload_dir, mock
406407
assert "some system exception" in ed.error.message
407408
assert ed.error.origin == execution_models.ExecutionError.ErrorKind.SYSTEM
408409

410+
@pytest.fixture
411+
def flyte_context():
412+
"""Fixture to set up a mock Flyte context."""
413+
with mock.patch.object(context_manager.FlyteContext, 'current_context', return_value=mock.Mock()):
414+
yield
415+
416+
def test_compute_array_job_index(flyte_context):
417+
assert _compute_array_job_index() == 0
418+
assert _compute_array_job_index(index=1) == 1
419+
assert _compute_array_job_index(index=2) == 2
409420

410421
def test_setup_disk_prefix():
411422
with setup_execution("qwerty") as ctx:

0 commit comments

Comments
 (0)