-
Notifications
You must be signed in to change notification settings - Fork 3
Feature/improve cloud schedule #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ErraticO
wants to merge
4
commits into
feature/improve-doc
Choose a base branch
from
feature/improve-cloud-schedule
base: feature/improve-doc
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5c8f9fb
lifecycle management(Improved)
ErraticO 8c853ad
Add pause/resume/list to aigear-scheduler CLI and add docstrings to s…
ErraticO 0c437e1
Update docs for aigear-scheduler full lifecycle commands
ErraticO 8de948e
Consolidate magic constants into domain-specific constant modules
ErraticO File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -98,21 +98,47 @@ aigear-task grpc --version VERSION | |||||||||||||
|
|
||||||||||||||
| ### `aigear-scheduler` | ||||||||||||||
|
|
||||||||||||||
| Create a Cloud Scheduler job that triggers the given pipeline steps. | ||||||||||||||
| Manage Cloud Scheduler jobs that trigger pipeline steps via Pub/Sub. | ||||||||||||||
|
|
||||||||||||||
| ``` | ||||||||||||||
| aigear-scheduler --version VERSION --step_names STEPS [--create] | ||||||||||||||
| aigear-scheduler <command> --version VERSION [--step_names STEPS] [--env ENV] | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| | Command | `--step_names` required | Description | | ||||||||||||||
| |---|---|---| | ||||||||||||||
| | `--create` | yes | Create a new scheduler job (skips if already exists) | | ||||||||||||||
| | `--update` | yes | Update schedule and message body of an existing job | | ||||||||||||||
| | `--delete` | — | Delete the scheduler job | | ||||||||||||||
| | `--status` | — | Print the current status of the scheduler job | | ||||||||||||||
| | `--list` | — | List scheduler jobs filtered by name | | ||||||||||||||
| | `--run` | — | Manually trigger the scheduler job immediately | | ||||||||||||||
| | `--pause` | — | Pause the scheduler job (stops automatic execution) | | ||||||||||||||
| | `--resume` | — | Resume a paused scheduler job | | ||||||||||||||
|
|
||||||||||||||
| | Argument | Default | Description | | ||||||||||||||
| |---|---|---| | ||||||||||||||
| | `--create` | — | Create GCP scheduler job. Runs by default if omitted. | | ||||||||||||||
| | `--version` | — | Pipeline version (required) | | ||||||||||||||
| | `--step_names` | — | Comma-separated step names, e.g. `fetch_data,training` (required) | | ||||||||||||||
| | `--version` | — | Pipeline version (required for all commands) | | ||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||
| | `--step_names` | — | Comma-separated step names, e.g. `fetch_data,training` (required for `--create` / `--update`) | | ||||||||||||||
| | `--env` | `staging` | Deployment environment for model service: `staging` or `production` | | ||||||||||||||
|
|
||||||||||||||
| **Examples** | ||||||||||||||
|
|
||||||||||||||
| ```bash | ||||||||||||||
| # Create a scheduler job for two pipeline steps | ||||||||||||||
| aigear-scheduler --create --version logistic_regression --step_names fetch_data,training | ||||||||||||||
|
|
||||||||||||||
| # Update the schedule or message body | ||||||||||||||
| aigear-scheduler --update --version logistic_regression --step_names fetch_data,training --env production | ||||||||||||||
|
|
||||||||||||||
| # Trigger an immediate run without waiting for the cron schedule | ||||||||||||||
| aigear-scheduler --run --version logistic_regression | ||||||||||||||
|
|
||||||||||||||
| # Pause / resume | ||||||||||||||
| aigear-scheduler --pause --version logistic_regression | ||||||||||||||
| aigear-scheduler --resume --version logistic_regression | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| > `--version` and `--step_names` are required; the command will print a reminder and exit if either is missing. | ||||||||||||||
| > | ||||||||||||||
| > Future commands: `--delete`, `--update`, `--run`... | ||||||||||||||
| > The scheduler job name, cron schedule, and Pub/Sub topic are read from the `scheduler` block in `env.json` for the given `--version`. | ||||||||||||||
|
|
||||||||||||||
| --- | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,48 +1,67 @@ | ||
| import argparse | ||
|
|
||
| from aigear.deploy.gcp.scheduler import create_scheduler | ||
| from aigear.deploy.gcp.scheduler import ( | ||
| create_scheduler, | ||
| update_scheduler, | ||
| delete_scheduler, | ||
| status_scheduler, | ||
| list_scheduler, | ||
| run_scheduler, | ||
| pause_scheduler, | ||
| resume_scheduler, | ||
| ) | ||
|
|
||
|
|
||
| def get_argument() -> argparse.Namespace: | ||
| parser = argparse.ArgumentParser( | ||
| description=__doc__, | ||
| formatter_class=argparse.RawDescriptionHelpFormatter) | ||
| group = parser.add_mutually_exclusive_group(required=True) | ||
| group.add_argument( | ||
| "--create", | ||
| action="store_true", | ||
| help="Create GCP scheduler job." | ||
| ) | ||
| # Future commands: | ||
| # group.add_argument("--delete", action="store_true", help="...") | ||
| # group.add_argument("--update", action="store_true", help="...") | ||
| group.add_argument("--create", action="store_true", help="Create GCP scheduler job.") | ||
| group.add_argument("--update", action="store_true", help="Update an existing GCP scheduler job.") | ||
| group.add_argument("--delete", action="store_true", help="Delete a GCP scheduler job.") | ||
| group.add_argument("--status", action="store_true", help="Show status of a GCP scheduler job.") | ||
| group.add_argument("--list", action="store_true", help="List GCP scheduler jobs filtered by name.") | ||
| group.add_argument("--run", action="store_true", help="Manually trigger a GCP scheduler job.") | ||
| group.add_argument("--pause", action="store_true", help="Pause a GCP scheduler job.") | ||
| group.add_argument("--resume", action="store_true", help="Resume a paused GCP scheduler job.") | ||
| parser.add_argument("--version", default="", | ||
| help="Version of the pipeline.") | ||
| parser.add_argument("--step_names", default="", | ||
| help="Comma-separated names of the pipeline steps.") | ||
| help="Comma-separated names of the pipeline steps (required for --create / --update).") | ||
| parser.add_argument("--env", default="staging", | ||
| choices=["staging", "production"], | ||
| help="Deployment environment for model service yaml (default: from env.json).") | ||
| help="Deployment environment for model service yaml (default: staging).") | ||
| return parser.parse_args() | ||
|
|
||
|
|
||
| def gcp_scheduler() -> None: | ||
| args = get_argument() | ||
|
|
||
| missing = [] | ||
| if not args.version: | ||
| missing.append("--version") | ||
| if not args.step_names: | ||
| missing.append("--step_names") | ||
| if missing: | ||
| print(f"Missing required argument(s): {', '.join(missing)}") | ||
| print("Missing required argument: --version") | ||
| return | ||
|
|
||
| step_names = args.step_names.split(",") | ||
| needs_step_names = args.create or args.update | ||
| if needs_step_names and not args.step_names: | ||
| print("Missing required argument: --step_names (required for --create / --update)") | ||
| return | ||
|
|
||
| step_names = args.step_names.split(",") if args.step_names else [] | ||
|
|
||
| if args.create: | ||
| create_scheduler(args.version, step_names, args.env) | ||
| # Future commands: | ||
| # elif args.delete: | ||
| # delete_scheduler(args.version, step_names) | ||
| # elif args.update: | ||
| # update_scheduler(args.version, step_names) | ||
| elif args.update: | ||
| update_scheduler(args.version, step_names, args.env) | ||
| elif args.delete: | ||
| delete_scheduler(args.version) | ||
| elif args.status: | ||
| status_scheduler(args.version) | ||
| elif args.list: | ||
| list_scheduler(args.version) | ||
| elif args.run: | ||
| run_scheduler(args.version) | ||
| elif args.pause: | ||
| pause_scheduler(args.version) | ||
| elif args.resume: | ||
| resume_scheduler(args.version) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the status returns ENABLED, PAUSED, missing, etc?