diff --git a/sdk/python/kfp_tekton/compiler/_data_passing_rewriter.py b/sdk/python/kfp_tekton/compiler/_data_passing_rewriter.py index 39246e6a6a5..2b4cc459725 100644 --- a/sdk/python/kfp_tekton/compiler/_data_passing_rewriter.py +++ b/sdk/python/kfp_tekton/compiler/_data_passing_rewriter.py @@ -623,7 +623,9 @@ def append_taskrun_params(task_name_append: str): 'TOTAL_SIZE=$( expr $TOTAL_SIZE + $ARTIFACT_SIZE)\n' + 'touch ' + dst + '\n' + # create an empty file by default. 'if [[ $TOTAL_SIZE -lt 3072 ]]; then\n' + - ' cp ' + src + ' ' + dst + '\n' + + ' if ! awk "/[^[:print:]]/{f=1} END{exit !f}" %s; then\n' % src + + ' cp ' + src + ' ' + dst + '\n' + + ' fi\n' 'fi\n' ) _append_original_pr_name_env_to_step(copy_results_artifact_step) diff --git a/sdk/python/tests/compiler/testdata/artifact_outputs.yaml b/sdk/python/tests/compiler/testdata/artifact_outputs.yaml index d6df3057f0a..35c05d06984 100644 --- a/sdk/python/tests/compiler/testdata/artifact_outputs.yaml +++ b/sdk/python/tests/compiler/testdata/artifact_outputs.yaml @@ -78,7 +78,9 @@ spec: TOTAL_SIZE=$( expr $TOTAL_SIZE + $ARTIFACT_SIZE) touch $(results.data.path) if [[ $TOTAL_SIZE -lt 3072 ]]; then - cp $(workspaces.gcs-download.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/data $(results.data.path) + if ! awk "/[^[:print:]]/{f=1} END{exit !f}" $(workspaces.gcs-download.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/data; then + cp $(workspaces.gcs-download.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/data $(results.data.path) + fi fi onError: continue env: diff --git a/sdk/python/tests/compiler/testdata/big_data_passing.yaml b/sdk/python/tests/compiler/testdata/big_data_passing.yaml index a837e2bf8f6..5d6aeebcbbc 100644 --- a/sdk/python/tests/compiler/testdata/big_data_passing.yaml +++ b/sdk/python/tests/compiler/testdata/big_data_passing.yaml @@ -111,7 +111,9 @@ spec: TOTAL_SIZE=$( expr $TOTAL_SIZE + $ARTIFACT_SIZE) touch $(results.output-text.path) if [[ $TOTAL_SIZE -lt 3072 ]]; then - cp $(workspaces.repeat-line.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/output_text $(results.output-text.path) + if ! awk "/[^[:print:]]/{f=1} END{exit !f}" $(workspaces.repeat-line.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/output_text; then + cp $(workspaces.repeat-line.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/output_text $(results.output-text.path) + fi fi onError: continue env: @@ -226,13 +228,17 @@ spec: TOTAL_SIZE=$( expr $TOTAL_SIZE + $ARTIFACT_SIZE) touch $(results.odd-lines.path) if [[ $TOTAL_SIZE -lt 3072 ]]; then - cp $(workspaces.split-text-lines.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/odd_lines $(results.odd-lines.path) + if ! awk "/[^[:print:]]/{f=1} END{exit !f}" $(workspaces.split-text-lines.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/odd_lines; then + cp $(workspaces.split-text-lines.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/odd_lines $(results.odd-lines.path) + fi fi ARTIFACT_SIZE=`wc -c $(workspaces.split-text-lines.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/even_lines | awk '{print $1}'` TOTAL_SIZE=$( expr $TOTAL_SIZE + $ARTIFACT_SIZE) touch $(results.even-lines.path) if [[ $TOTAL_SIZE -lt 3072 ]]; then - cp $(workspaces.split-text-lines.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/even_lines $(results.even-lines.path) + if ! awk "/[^[:print:]]/{f=1} END{exit !f}" $(workspaces.split-text-lines.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/even_lines; then + cp $(workspaces.split-text-lines.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/even_lines $(results.even-lines.path) + fi fi onError: continue env: @@ -446,7 +452,9 @@ spec: TOTAL_SIZE=$( expr $TOTAL_SIZE + $ARTIFACT_SIZE) touch $(results.numbers.path) if [[ $TOTAL_SIZE -lt 3072 ]]; then - cp $(workspaces.write-numbers.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/numbers $(results.numbers.path) + if ! awk "/[^[:print:]]/{f=1} END{exit !f}" $(workspaces.write-numbers.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/numbers; then + cp $(workspaces.write-numbers.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/numbers $(results.numbers.path) + fi fi onError: continue env: @@ -614,7 +622,9 @@ spec: TOTAL_SIZE=$( expr $TOTAL_SIZE + $ARTIFACT_SIZE) touch $(results.output.path) if [[ $TOTAL_SIZE -lt 3072 ]]; then - cp $(workspaces.sum-numbers.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/Output $(results.output.path) + if ! awk "/[^[:print:]]/{f=1} END{exit !f}" $(workspaces.sum-numbers.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/Output; then + cp $(workspaces.sum-numbers.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/Output $(results.output.path) + fi fi onError: continue env: diff --git a/sdk/python/tests/compiler/testdata/create_component_from_func.yaml b/sdk/python/tests/compiler/testdata/create_component_from_func.yaml index 3d6823f1ac9..769cd3b794e 100644 --- a/sdk/python/tests/compiler/testdata/create_component_from_func.yaml +++ b/sdk/python/tests/compiler/testdata/create_component_from_func.yaml @@ -101,7 +101,9 @@ spec: TOTAL_SIZE=$( expr $TOTAL_SIZE + $ARTIFACT_SIZE) touch $(results.output-dir.path) if [[ $TOTAL_SIZE -lt 3072 ]]; then - cp $(workspaces.produce-dir-with-files-python-op.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/output_dir $(results.output-dir.path) + if ! awk "/[^[:print:]]/{f=1} END{exit !f}" $(workspaces.produce-dir-with-files-python-op.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/output_dir; then + cp $(workspaces.produce-dir-with-files-python-op.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/output_dir $(results.output-dir.path) + fi fi onError: continue env: @@ -170,7 +172,9 @@ spec: TOTAL_SIZE=$( expr $TOTAL_SIZE + $ARTIFACT_SIZE) touch $(results.subdir.path) if [[ $TOTAL_SIZE -lt 3072 ]]; then - cp $(workspaces.get-subdirectory.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/Subdir $(results.subdir.path) + if ! awk "/[^[:print:]]/{f=1} END{exit !f}" $(workspaces.get-subdirectory.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/Subdir; then + cp $(workspaces.get-subdirectory.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/Subdir $(results.subdir.path) + fi fi onError: continue env: diff --git a/sdk/python/tests/compiler/testdata/data_passing_pipeline_complete.yaml b/sdk/python/tests/compiler/testdata/data_passing_pipeline_complete.yaml index 97eb5bc4b55..f431433d1e2 100644 --- a/sdk/python/tests/compiler/testdata/data_passing_pipeline_complete.yaml +++ b/sdk/python/tests/compiler/testdata/data_passing_pipeline_complete.yaml @@ -131,7 +131,9 @@ spec: TOTAL_SIZE=$( expr $TOTAL_SIZE + $ARTIFACT_SIZE) touch $(results.data.path) if [[ $TOTAL_SIZE -lt 3072 ]]; then - cp $(workspaces.produce-anything.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/data $(results.data.path) + if ! awk "/[^[:print:]]/{f=1} END{exit !f}" $(workspaces.produce-anything.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/data; then + cp $(workspaces.produce-anything.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/data $(results.data.path) + fi fi onError: continue env: @@ -212,7 +214,9 @@ spec: TOTAL_SIZE=$( expr $TOTAL_SIZE + $ARTIFACT_SIZE) touch $(results.data.path) if [[ $TOTAL_SIZE -lt 3072 ]]; then - cp $(workspaces.produce-something.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/data $(results.data.path) + if ! awk "/[^[:print:]]/{f=1} END{exit !f}" $(workspaces.produce-something.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/data; then + cp $(workspaces.produce-something.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/data $(results.data.path) + fi fi onError: continue env: @@ -311,7 +315,9 @@ spec: TOTAL_SIZE=$( expr $TOTAL_SIZE + $ARTIFACT_SIZE) touch $(results.output.path) if [[ $TOTAL_SIZE -lt 3072 ]]; then - cp $(workspaces.produce-string.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/Output $(results.output.path) + if ! awk "/[^[:print:]]/{f=1} END{exit !f}" $(workspaces.produce-string.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/Output; then + cp $(workspaces.produce-string.path)/artifacts/$ORIG_PR_NAME/$(context.taskRun.name)/Output $(results.output.path) + fi fi onError: continue env: diff --git a/sdk/python/tests/compiler/testdata/many_results.yaml b/sdk/python/tests/compiler/testdata/many_results.yaml index fec0e95e0c0..ca65a33fdae 100644 --- a/sdk/python/tests/compiler/testdata/many_results.yaml +++ b/sdk/python/tests/compiler/testdata/many_results.yaml @@ -119,13 +119,17 @@ spec: TOTAL_SIZE=$( expr $TOTAL_SIZE + $ARTIFACT_SIZE) touch $(results.param1.path) if [[ $TOTAL_SIZE -lt 3072 ]]; then - cp /tekton/home/tep-results/param1 $(results.param1.path) + if ! awk "/[^[:print:]]/{f=1} END{exit !f}" /tekton/home/tep-results/param1; then + cp /tekton/home/tep-results/param1 $(results.param1.path) + fi fi ARTIFACT_SIZE=`wc -c /tekton/home/tep-results/param3-b | awk '{print $1}'` TOTAL_SIZE=$( expr $TOTAL_SIZE + $ARTIFACT_SIZE) touch $(results.param3-b.path) if [[ $TOTAL_SIZE -lt 3072 ]]; then - cp /tekton/home/tep-results/param3-b $(results.param3-b.path) + if ! awk "/[^[:print:]]/{f=1} END{exit !f}" /tekton/home/tep-results/param3-b; then + cp /tekton/home/tep-results/param3-b $(results.param3-b.path) + fi fi onError: continue env: diff --git a/sdk/python/tests/compiler/testdata/many_results_with_warnings.yaml b/sdk/python/tests/compiler/testdata/many_results_with_warnings.yaml index 412253c9758..3273d9323f5 100644 --- a/sdk/python/tests/compiler/testdata/many_results_with_warnings.yaml +++ b/sdk/python/tests/compiler/testdata/many_results_with_warnings.yaml @@ -119,19 +119,25 @@ spec: TOTAL_SIZE=$( expr $TOTAL_SIZE + $ARTIFACT_SIZE) touch $(results.param2.path) if [[ $TOTAL_SIZE -lt 3072 ]]; then - cp /tekton/home/tep-results/param2 $(results.param2.path) + if ! awk "/[^[:print:]]/{f=1} END{exit !f}" /tekton/home/tep-results/param2; then + cp /tekton/home/tep-results/param2 $(results.param2.path) + fi fi ARTIFACT_SIZE=`wc -c /tekton/home/tep-results/param3 | awk '{print $1}'` TOTAL_SIZE=$( expr $TOTAL_SIZE + $ARTIFACT_SIZE) touch $(results.param3.path) if [[ $TOTAL_SIZE -lt 3072 ]]; then - cp /tekton/home/tep-results/param3 $(results.param3.path) + if ! awk "/[^[:print:]]/{f=1} END{exit !f}" /tekton/home/tep-results/param3; then + cp /tekton/home/tep-results/param3 $(results.param3.path) + fi fi ARTIFACT_SIZE=`wc -c /tekton/home/tep-results/superlongnamesuperlongnamesuperlongnamesuperlongnamesuper | awk '{print $1}'` TOTAL_SIZE=$( expr $TOTAL_SIZE + $ARTIFACT_SIZE) touch $(results.superlongnamesuperlongnamesuperlongnamesuperlongnamesuper.path) if [[ $TOTAL_SIZE -lt 3072 ]]; then - cp /tekton/home/tep-results/superlongnamesuperlongnamesuperlongnamesuperlongnamesuper $(results.superlongnamesuperlongnamesuperlongnamesuperlongnamesuper.path) + if ! awk "/[^[:print:]]/{f=1} END{exit !f}" /tekton/home/tep-results/superlongnamesuperlongnamesuperlongnamesuperlongnamesuper; then + cp /tekton/home/tep-results/superlongnamesuperlongnamesuperlongnamesuperlongnamesuper $(results.superlongnamesuperlongnamesuperlongnamesuperlongnamesuper.path) + fi fi onError: continue env: