Skip to content

Commit

Permalink
Remove app, mod, software files and add --file arg
Browse files Browse the repository at this point in the history
  • Loading branch information
dapomeroy committed Jan 9, 2025
1 parent 3809e5a commit ddb68e4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 81 deletions.
55 changes: 12 additions & 43 deletions lib/ramble/ramble/cmd/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,15 @@ def workspace_list(args):

def workspace_edit_setup_parser(subparser):
"""edit workspace config or template"""
subparser.add_argument(
"-f",
"--file",
dest="file_to_edit",
default=None,
help="Open a single file by filename",
required=False,
)

subparser.add_argument(
"-c",
"--config_only",
Expand All @@ -848,33 +857,6 @@ def workspace_edit_setup_parser(subparser):
required=False,
)

subparser.add_argument(
"-a",
"--applications_only",
dest="applications_only",
action="store_true",
help="Only open applications files",
required=False,
)

subparser.add_argument(
"-m",
"--modifiers_only",
dest="modifiers_only",
action="store_true",
help="Only open modifiers files",
required=False,
)

subparser.add_argument(
"-s",
"--software_only",
dest="software_only",
action="store_true",
help="Only open software files",
required=False,
)

subparser.add_argument(
"-t",
"--template_only",
Expand Down Expand Up @@ -916,28 +898,15 @@ def workspace_edit(args):
)

config_file = ramble.workspace.config_file(ramble_ws)
applications_file = ramble.workspace.applications_file(ramble_ws)
modifiers_file = ramble.workspace.modifiers_file(ramble_ws)
software_file = ramble.workspace.software_file(ramble_ws)
template_files = ramble.workspace.all_template_paths(ramble_ws)

edit_files = [config_file]
optional_files = [applications_file, modifiers_file, software_file]

for file in optional_files:
if file and os.path.exists(file):
edit_files.append(file)

edit_files.extend(template_files)

if args.config_only:
if args.file_to_edit:
edit_files = [ramble.workspace.get_yaml_filepath(ramble_ws, args.file_to_edit)]
elif args.config_only:
edit_files = [config_file]
elif args.applications_only:
edit_files = [applications_file]
elif args.modifiers_only:
edit_files = [modifiers_file]
elif args.software_only:
edit_files = [software_file]
elif args.template_only:
edit_files = template_files
elif args.license_only:
Expand Down
10 changes: 3 additions & 7 deletions lib/ramble/ramble/test/cmd/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,18 +866,14 @@ def test_edit_edits_correct_paths():
ws.write()

config_file = ramble.workspace.config_file(ws.root)
applications_file = ramble.workspace.applications_file(ws.root)
modifiers_file = ramble.workspace.modifiers_file(ws.root)
software_file = ramble.workspace.software_file(ws.root)
default_template_path = ws.template_path("execute_experiment")

ws_args = ["-w", "test"]
assert workspace("edit", "-c", "--print-file", global_args=ws_args).strip() == config_file
assert (
workspace("edit", "-a", "--print-file", global_args=ws_args).strip() == applications_file
workspace("edit", "-f", "ramble.yaml", "--print-file", global_args=ws_args).strip()
== config_file
)
assert workspace("edit", "-m", "--print-file", global_args=ws_args).strip() == modifiers_file
assert workspace("edit", "-s", "--print-file", global_args=ws_args).strip() == software_file
assert workspace("edit", "-c", "--print-file", global_args=ws_args).strip() == config_file
assert (
workspace("edit", "-t", "--print-file", global_args=ws_args).strip()
== default_template_path
Expand Down
14 changes: 2 additions & 12 deletions lib/ramble/ramble/workspace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,9 @@
exists,
is_workspace_dir,
get_workspace_path,
get_yaml_filepath,
config_file,
config_file_name,
applications_file,
applications_file_name,
modifiers_file,
modifiers_file_name,
software_file,
software_file_name,
all_config_files,
licenses_file,
licenses_file_name,
Expand Down Expand Up @@ -77,14 +72,9 @@
"exists",
"is_workspace_dir",
"get_workspace_path",
"get_yaml_filepath",
"config_file",
"config_file_name",
"applications_file",
"applications_file_name",
"modifiers_file",
"modifiers_file_name",
"software_file",
"software_file_name",
"all_config_files",
"licenses_file",
"licenses_file_name",
Expand Down
18 changes: 0 additions & 18 deletions lib/ramble/ramble/workspace/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@
config_schema = ramble.schema.workspace.schema
config_section = "workspace"
config_file_name = "ramble.yaml"
applications_file_name = "applications.yaml"
modifiers_file_name = "modifiers.yaml"
software_file_name = "software.yaml"
licenses_file_name = "licenses.yaml"

metadata_file_name = "workspace_metadata.yaml"
Expand Down Expand Up @@ -272,21 +269,6 @@ def config_file(path):
return get_yaml_filepath(path, config_file_name)


def applications_file(path):
"""Returns the path to a workspace's applications.yaml"""
return get_yaml_filepath(path, applications_file_name)


def modifiers_file(path):
"""Returns the path to a workspace's modifiers.yaml"""
return get_yaml_filepath(path, modifiers_file_name)


def software_file(path):
"""Returns the path to a workspace's software.yaml"""
return get_yaml_filepath(path, software_file_name)


def licenses_file(path):
"""Returns the path to a workspace's licenses.yaml"""
return get_yaml_filepath(path, licenses_file_name)
Expand Down
2 changes: 1 addition & 1 deletion share/ramble/ramble-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ _ramble_workspace_info() {
}

_ramble_workspace_edit() {
RAMBLE_COMPREPLY="-h --help -c --config_only -a --applications_only -m --modifiers_only -s --software_only -t --template_only -l --license_only --all -p --print-file"
RAMBLE_COMPREPLY="-h --help -f --file -c --config_only -t --template_only -l --license_only --all -p --print-file"
}

_ramble_workspace_mirror() {
Expand Down

0 comments on commit ddb68e4

Please sign in to comment.