This repository has been archived by the owner on Jan 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopy_project.py
60 lines (53 loc) · 1.8 KB
/
copy_project.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#! venv/bin/python
"""
Copy project CLI command.
"""
import argparse
from dev.tools.copy_project import CopyProject, CopyProjectFailed
def extract_args(cli_args) -> tuple:
"""
Function extracts args from cli command.
"""
return cli_args.id, cli_args.source, cli_args.destination
# @TODO: Add STRATIFY = "Stratify" handling?
if __name__ == "__main__":
# Initialize parser
parser = argparse.ArgumentParser()
parser.add_argument(
"-i", "--id", help="The id for the project in the source system."
)
parser.add_argument(
"-s",
"--source",
help="The source URL to copy the project from including protocol and port (if needed). "
"E.g. http://localhost:8001",
)
parser.add_argument(
"-d",
"--destination",
help="The destination URL to copy the project to including protocol and port "
"(if needed). E.g. http://localhost:8001",
)
args = parser.parse_args()
project_id, source_url, destination_url = extract_args(args)
if project_id and source_url and destination_url:
print("Running copy project operation.")
copy_class = CopyProject(
pid=project_id, source=source_url, dest=destination_url
)
# Copy the project.
copy_class.copy_project_obj()
# Process the project assets. E.g. datasets, artifacts
copy_class.process_assets()
# Process the workflow objects.
copy_class.process_workflows()
# Validate the copy operation.
try:
copy_class.validate_copy()
print("Copy project completed.")
exit(0)
except CopyProjectFailed as e_:
print(e_.message)
else:
print("Missing required CLI option: project id, source url, or destination url")
exit(1)