Skip to content

Commit

Permalink
Copy artifacts should make the file names unique by appending a suffi…
Browse files Browse the repository at this point in the history
…x. (kubeflow#183)

* Copy artifacts should make the file names unique by appending a suffix.

* See kubeflow/training-operator#748
* A test can run multiple instances of a workflow but with different parameters.
* In this case we need to make sure the junit files and other artifacts
  copied to GCS for gubernator have unique names.

* One way to make this easier is to have copy-artifacts automatically
  append a unique suffix to each file before copying it to GCS.

* Fix lint.
  • Loading branch information
jlewi authored and k8s-ci-robot committed Jul 24, 2018
1 parent a61f638 commit f611369
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions py/kubeflow/testing/prow_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ def copy_artifacts(args):

output = get_gcs_dir(args.bucket)

if args.suffix:
logging.info("Renaming all artifact files to include %s", args.suffix)
for dirpath, _, files in os.walk(args.artifacts_dir):
for filename in files:
full_path = os.path.join(dirpath, filename)

name, ext = os.path.splitext(filename)
new_name = "{0}-{1}{2}".format(name, args.suffix, ext)
new_path = os.path.join(dirpath, new_name)
logging.info("Rename %s to %s", full_path, new_path)
os.rename(full_path, new_path)
util.maybe_activate_service_account()
util.run(["gsutil", "-m", "rsync", "-r", args.artifacts_dir, output])

Expand Down Expand Up @@ -255,6 +266,13 @@ def main(unparsed_args=None): # pylint: disable=too-many-locals
type=str,
help="Bucket to copy the artifacts to.")

parser_copy.add_argument(
"--suffix",
default="",
type=str,
help=("Optional if supplied add this suffix to the names of all artifact "
"files before copying them to the GCS bucket."))

parser_copy.set_defaults(func=copy_artifacts)

#############################################################################
Expand Down
1 change: 1 addition & 0 deletions workflows/components/workflows.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
"--artifacts_dir=" + outputDir,
"copy_artifacts",
"--bucket=" + bucket,
"--suffix=fakesuffix",
]), // copy-artifacts
], // templates
},
Expand Down

0 comments on commit f611369

Please sign in to comment.