Skip to content

Commit

Permalink
Prepare for direct inference by renaming the flag in cli (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
ezyang committed Aug 10, 2024
1 parent 4a946a3 commit 0ed013b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
18 changes: 12 additions & 6 deletions ghstack/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ def cli_context(
@click.option("--force", is_flag=True, hidden=True)
@click.option("--no-skip", is_flag=True, hidden=True)
@click.option("--draft", is_flag=True, hidden=True)
@click.option("--direct", is_flag=True, hidden=True)
@click.option(
"--direct/--no-direct", "direct_opt", is_flag=True, hidden=True, default=None
)
@click.option("--base", "-B", default=None, hidden=True)
@click.option("--stack/--no-stack", "-s/-S", is_flag=True, default=True, hidden=True)
def main(
Expand All @@ -67,7 +69,7 @@ def main(
update_fields: bool,
short: bool,
force: bool,
direct: bool,
direct_opt: Optional[bool],
no_skip: bool,
draft: bool,
base: Optional[str],
Expand All @@ -89,7 +91,7 @@ def main(
draft=draft,
base=base,
stack=stack,
direct=direct,
direct_opt=direct_opt,
)


Expand Down Expand Up @@ -226,7 +228,11 @@ def status(pull_request: str) -> None:
"listed in the command line.",
)
@click.option(
"--direct", is_flag=True, help="Create stack that directly merges into master"
"--direct/--no-direct",
"direct_opt",
default=None,
is_flag=True,
help="Create stack that directly merges into master",
)
@click.argument(
"revs",
Expand All @@ -240,7 +246,7 @@ def submit(
force: bool,
no_skip: bool,
draft: bool,
direct: bool,
direct_opt: Optional[bool],
base: Optional[str],
revs: Tuple[str, ...],
stack: bool,
Expand All @@ -264,7 +270,7 @@ def submit(
base_opt=base,
revs=revs,
stack=stack,
direct=direct,
direct_opt=direct_opt,
)


Expand Down
7 changes: 5 additions & 2 deletions ghstack/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ class Submitter:

# Instead of merging into base branch, merge directly into the appropriate
# main or head branch. Change merge targets appropriately as PRs get
# merged
direct: bool = False
# merged. If None, infer whether or not the PR should be direct or not.
direct_opt: Optional[bool] = None

# ~~~~~~~~~~~~~~~~~~~~~~~~
# Computed in post init
Expand All @@ -356,6 +356,8 @@ class Submitter:

base: str = dataclasses.field(init=False)

direct: bool = dataclasses.field(init=False)

# ~~~~~~~~~~~~~~~~~~~~~~~~
# Mutable state; TODO: remove me

Expand Down Expand Up @@ -404,6 +406,7 @@ def __post_init__(self) -> None:
default_branch = repo["default_branch"]

object.__setattr__(self, "base", default_branch)
object.__setattr__(self, "direct", bool(self.direct_opt))

# ~~~~~~~~~~~~~~~~~~~~~~~~
# The main algorithm
Expand Down
2 changes: 1 addition & 1 deletion ghstack/test_prelude.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def gh_submit(
repo_owner_opt="pytorch",
repo_name_opt="pytorch",
short=short,
direct=self.direct,
direct_opt=self.direct,
no_skip=no_skip,
github_url="github.com",
remote_name="origin",
Expand Down

0 comments on commit 0ed013b

Please sign in to comment.