Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

DM-42229: specialize create functions in cli wrappers #26

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/lsst/cmservice/cli/campaign.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
"""CLI to manage Campaign table"""
from .. import db
from . import wrappers
from . import options, wrappers
from .commands import campaign_group

# Template specialization
# Specify the cli path to attach these commands to
cli_group = campaign_group
# Specify the associated database table
db_class = db.Campaign
# Specify the options for the create command
create_options = [
options.cmclient(),
options.name(),
options.data(),
options.child_config(),
options.collections(),
options.spec_aliases(),
options.handler(),
options.parent_name(),
options.spec_name(),
options.spec_block_name(),
options.spec_block_assoc_name(),
options.output(),
]


# Construct derived templates
group_command = cli_group.command
Expand Down Expand Up @@ -41,7 +57,7 @@ def action() -> None:
# Add functions to the router
get_rows = wrappers.get_list_command(group_command, sub_client, db_class)

create = wrappers.get_create_command(group_command, sub_client, db_class)
create = wrappers.get_create_command(group_command, sub_client, db_class, create_options)

delete = wrappers.get_delete_command(group_command, sub_client)

Expand Down
19 changes: 17 additions & 2 deletions src/lsst/cmservice/cli/group.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
"""CLI to manage Group table"""
from .. import db
from . import wrappers
from . import options, wrappers
from .commands import group_group

# Template specialization
# Specify the cli path to attach these commands to
cli_group = group_group
# Specify the associated database table
db_class = db.Group
# Specify the options for the create command
create_options = [
options.cmclient(),
options.name(),
options.data(),
options.child_config(),
options.collections(),
options.spec_aliases(),
options.handler(),
options.parent_name(),
options.spec_name(),
options.spec_block_name(),
options.spec_block_assoc_name(),
options.output(),
]

# Construct derived templates
group_command = cli_group.command
Expand Down Expand Up @@ -41,7 +56,7 @@ def action() -> None:
# Add functions to the router
get_rows = wrappers.get_list_command(group_command, sub_client, db_class)

create = wrappers.get_create_command(group_command, sub_client, db_class)
create = wrappers.get_create_command(group_command, sub_client, db_class, create_options)

delete = wrappers.get_delete_command(group_command, sub_client)

Expand Down
19 changes: 17 additions & 2 deletions src/lsst/cmservice/cli/job.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
"""CLI to manage Job table"""
from .. import db
from . import wrappers
from . import options, wrappers
from .commands import job_group

# Template specialization
# Specify the cli path to attach these commands to
cli_group = job_group
db_class = db.Job
# Specify the options for the create command
create_options = [
options.cmclient(),
options.name(),
options.data(),
options.child_config(),
options.collections(),
options.spec_aliases(),
options.handler(),
options.parent_name(),
options.spec_name(),
options.spec_block_name(),
options.spec_block_assoc_name(),
options.output(),
]

# Construct derived templates
group_command = cli_group.command
Expand Down Expand Up @@ -40,7 +55,7 @@ def action() -> None:
# Add functions to the router
get_rows = wrappers.get_list_command(group_command, sub_client, db_class)

create = wrappers.get_create_command(group_command, sub_client, db_class)
create = wrappers.get_create_command(group_command, sub_client, db_class, create_options)

delete = wrappers.get_delete_command(group_command, sub_client)

Expand Down
Loading