profile
viewpoint
Huon Wilson huonw @xoflare Sydney, Australia https://huonw.github.io/ Formerly: @data61, Swift frontend @apple, core team @rust-lang

Gankra/collect-rs 67

Miscellaneous Collections

brendanzab/algebra 59

Abstract algebra for Rust (still very much a WIP!)

huonw/brainfuck_macros 57

A brainfuck procedural macro for Rust

a-scie/jump 22

A Self Contained Interpreted Executable Launcher

huonw/2048-4D 21

2048, in 4d

brendanzab/rusp 15

A minimal scripting and data language for Rust.

huonw/alias 10

alias offers some basic ways to mutate data while aliased.

pull request commentpantsbuild/pants

Add cherry-pick PRs to their milestone for better visibility

Seems to work, e.g. https://github.com/pantsbuild/pants/pull/19255

image

huonw

comment created time in 22 minutes

delete branch huonw/pants

delete branch : bugfix/19248-globs

delete time in 25 minutes

issue closedpantsbuild/pants

`from ..foo import *` glob imports are silently ignored by Rust parser

Describe the bug

The new Rust parser doesn't seem to understand a 'plain' parent import, like from ..file1 import *. It does understand from ..file1 import func, though.

This reproducer constructs a directory structure like:

.
├── pants.toml
└── src
    └── a
        ├── BUILD
        ├── file1.py
        └── file2.py

where file2.py has from .file1 import *. It runs pants peek src/a/file2.py with both the python parser (which shows a dependency on src/a/file1.py) and with the Rust parser (which doesn't). Unlike #19173, there's no inference warnings either.

cd $(mktemp -d)

cat > pants.toml <<EOF
[GLOBAL]
pants_version = "2.17.0rc0"

backend_packages = ["pants.backend.python"]

[python]
interpreter_constraints = [">=3.8"]

[python-infer]
use_rust_parser = false
EOF

# set up the file structure:
mkdir -p src/a
touch src/a/file1.py
echo "from .file1 import *" > src/a/file2.py

echo "python_sources()" > src/a/BUILD

tree .

# OK: with Python parser `"dependencies": ["src/a/file1.py"]`
pants peek src/a/file2.py

# flip to the rust parser
sed -i '' 's/use_rust_parser = false/use_rust_parser = true/' pants.toml

# BUG: with Rust parser `"dependencies": []`
pants peek src/a/file2.py

Pants version 2.17.0rc0

OS macOS

Additional info #19173

closed time in 25 minutes

huonw

issue closedpantsbuild/pants

`from ..foo import *` glob imports are silently ignored by Rust parser

Describe the bug

The new Rust parser doesn't seem to understand a 'plain' parent import, like from ..file1 import *. It does understand from ..file1 import func, though.

This reproducer constructs a directory structure like:

.
├── pants.toml
└── src
    └── a
        ├── BUILD
        ├── file1.py
        └── file2.py

where file2.py has from .file1 import *. It runs pants peek src/a/file2.py with both the python parser (which shows a dependency on src/a/file1.py) and with the Rust parser (which doesn't). Unlike #19173, there's no inference warnings either.

cd $(mktemp -d)

cat > pants.toml <<EOF
[GLOBAL]
pants_version = "2.17.0rc0"

backend_packages = ["pants.backend.python"]

[python]
interpreter_constraints = [">=3.8"]

[python-infer]
use_rust_parser = false
EOF

# set up the file structure:
mkdir -p src/a
touch src/a/file1.py
echo "from .file1 import *" > src/a/file2.py

echo "python_sources()" > src/a/BUILD

tree .

# OK: with Python parser `"dependencies": ["src/a/file1.py"]`
pants peek src/a/file2.py

# flip to the rust parser
sed -i '' 's/use_rust_parser = false/use_rust_parser = true/' pants.toml

# BUG: with Rust parser `"dependencies": []`
pants peek src/a/file2.py

Pants version 2.17.0rc0

OS macOS

Additional info #19173

closed time in 25 minutes

huonw

push eventpantsbuild/pants

Huon Wilson

commit sha ea97fa814ec34ea19333d5faa0fd04166a031602

Handle `from foo import *` wildcard imports in Rust dep inference parser (#19249) This fixes #19248 by implementing explicit handling for `*` wildcard imports in the Rust-based Python dependency inference parser. The commits are somewhat individually reviewable: 1. switching how the `insert_import` arguments are consumed from the syntax tree, for `from ... import ...` statements in particular: - before: `name` and `module_name` correspond to `import $name`, `"$name"`, `from $module_name import $name` - after: `base` and `imported` correspond to `import $base`, `"$base"`, `from $base import $imported` - This is in particular flipping the last one, and changes whether the `from ...` part is the optional arg (before) or not (after). - The motivation is that there's more functional similarities between the `from ...` part and a plain `import ...` statement, than between the `import ...` part and a plain `import ...` statement, despite the superficial similarities of it! (`from foo import bar` is a little like `import foo as __secret; bar = __secret.bar`.) 2. Add some tests that fail 3. Fix the bug 4. (and others) some tweaks, including defence-in-depth against similar problems happening in future

view details

push time in 25 minutes

PR merged pantsbuild/pants

Handle `from foo import *` wildcard imports in Rust dep inference parser needs-cherrypick category:internal

This fixes #19248 by implementing explicit handling for * wildcard imports in the Rust-based Python dependency inference parser.

The commits are somewhat individually reviewable:

  1. switching how the insert_import arguments are consumed from the syntax tree, for from ... import ... statements in particular:
    • before: name and module_name correspond to import $name, "$name", from $module_name import $name
    • after: base and imported correspond to import $base, "$base", from $base import $imported
    • This is in particular flipping the last one, and changes whether the from ... part is the optional arg (before) or not (after).
    • The motivation is that there's more functional similarities between the from ... part and a plain import ... statement, than between the import ... part and a plain import ... statement, despite the superficial similarities of it! (from foo import bar is a little like import foo as __secret; bar = __secret.bar.)
  2. Add some tests that fail
  3. Fix the bug
  4. (and others) some tweaks, including defence-in-depth against similar problems happening in future
+104 -28

2 comments

2 changed files

huonw

pr closed time in 25 minutes

delete branch huonw/pants

delete branch : feature/cherry-pick-milestone

delete time in 26 minutes

push eventpantsbuild/pants

Huon Wilson

commit sha 6ba6d8837c66596e41485af39cd75e91b85fdad0

Add cherry-pick PRs to their milestone for better visibility (#19254) This adjusts the cherry picking to create the PRs with a milestone attached, so that they're surfaced in the milestone views like https://github.com/pantsbuild/pants/milestone/58, alongside any pending issues and not-yet-cherrypicked PRs. In particular, if a PR is going to be cherry-picked, it'll have the milestone attached and be visible in that view (and any issues it's fixing may also have it tagged)... but once PR merges to `main`, it and any associated issues will be closed. This means they disappear from the milestone view, but there's still work remaining to actually fix them for that milestone: landing the cherry-pick. Pending cherry-pick PRs _can_ be discovered by doing a search like `base:2.17.x` https://github.com/pantsbuild/pants/pulls?q=is%3Apr+is%3Aopen+base%3A2.17.x but it's nice to have only one place to check (the milestone view) rather than needing to remember to also construct that search manually. This is a response to https://github.com/pantsbuild/pants/pull/19110 sitting around for a while and delaying 2.16, due to flaky CI failures: it was hard to notice. See also https://pantsbuild.slack.com/archives/C0D7TNJHL/p1685929902870459 / https://chat.pantsbuild.org/t/12317552/looks-like-https-github-com-pantsbuild-pants-pull-19110-neve#4a387fb1-fc0c-4395-9160-74adf8ab7944 (This will cause some conflicts with #19230, but this PR is a quick win that's easily ported over.)

view details

push time in 26 minutes

PR merged pantsbuild/pants

Add cherry-pick PRs to their milestone for better visibility category:internal

This adjusts the cherry picking to create the PRs with a milestone attached, so that they're surfaced in the milestone views like https://github.com/pantsbuild/pants/milestone/58, alongside any pending issues and not-yet-cherrypicked PRs.

In particular, if a PR is going to be cherry-picked, it'll have the milestone attached and be visible in that view (and any issues it's fixing may also have it tagged)... but once PR merges to main, it and any associated issues will be closed. This means they disappear from the milestone view, but there's still work remaining to actually fix them for that milestone: landing the cherry-pick. Pending cherry-pick PRs can be discovered by doing a search like base:2.17.x, but it's nice to have only one place to check (the milestone view) rather than needing to remember to also construct that search manually.

This is a response to https://github.com/pantsbuild/pants/pull/19110 sitting around for a while and delaying 2.16, due to flaky CI failures: it was hard to notice.

See also https://pantsbuild.slack.com/archives/C0D7TNJHL/p1685929902870459 / https://chat.pantsbuild.org/t/12317552/looks-like-https-github-com-pantsbuild-pants-pull-19110-neve#4a387fb1-fc0c-4395-9160-74adf8ab7944

(This will cause some conflicts with #19230, but this PR is a quick win that's easily ported over.)

+1 -1

0 comment

1 changed file

huonw

pr closed time in 26 minutes

PR opened pantsbuild/pants

Add cherry-pick PRs to their milestone for better visibility category:internal

This adjusts the cherry picking to create the PRs with a milestone attached, so that they're surfaced in the milestone views like https://github.com/pantsbuild/pants/milestone/58, alongside any pending issues and not-yet-cherrypicked PRs.

In particular, if a PR is going to be cherry-picked, it'll have the milestone attached and be visible in that view (and any issues it's fixing may also have it tagged)... but once PR merges to main, it and any associated issues will be closed. This means they disappear from the milestone view, but there's still work remaining to actually fix them for that milestone: landing the cherry-pick. Pending cherry-pick PRs can be discovered by doing a search like base:2.17.x, but it's nice to have only one place to check (the milestone view) rather than needing to remember to also construct that search manually.

This is a response to https://github.com/pantsbuild/pants/pull/19110 sitting around for a while and delaying 2.16, due to flaky CI failures: it was hard to notice.

See also https://pantsbuild.slack.com/archives/C0D7TNJHL/p1685929902870459 / https://chat.pantsbuild.org/t/12317552/looks-like-https-github-com-pantsbuild-pants-pull-19110-neve#4a387fb1-fc0c-4395-9160-74adf8ab7944

(This will cause some conflicts with #19230, but is a quick win that's easily ported over.)

+1 -1

0 comment

1 changed file

pr created time in 2 hours

create barnchhuonw/pants

branch : feature/cherry-pick-milestone

created branch time in 2 hours

PR opened pantsbuild/pants

Include complete platforms for FaaS environments for more reliable building

This changes the behaviour of the runtime field of the python_aws_lambda_function, python_aws_lambda_layer and python_google_cloud_function FaaS targets to be translated into a Pants-provided complete platform (if known), rather than using the less specific --platform argument.

For example, when building a target like python_aws_lambda_function(..., runtime="python3.10"), Pants will pull out an appropriate complete platform resources and use that when building the Lambda function to choose the correct wheels.

This is motivated by:

  1. the FaaS runtimes generally being stable (AIUI), so it's actually reasonable/possible to provide this
  2. the naive wheel selection for --platform often fails and users have to switch to using complete platforms themselves, and, one can still use complete_platforms manually, so this is not worse
  3. the switch to layout = "zip" means that passing both runtime="..." and complete_platforms=[...] will fail, as one --platform=... or --complete-platform=... argument can be passed to the underlying PEX call

The moving parts are:

  1. a script build-support/bin/generate_faas_complete_platforms.py that reads information about each FaaS system, including runtime docker repo and the tags for each 'known runtime', and shells out to docker to extra a complete platform JSON file
  2. if complete_platforms isn't specified, convert the runtime a complete platform argument (if it's known), or continue falling back to the naive --platform style

Notes:

  • Notable failing: this is only implemented for AWS: I cannot find an equivalent to https://gallery.ecr.aws/lambda/python for GCF, so despite being generic infrastructure, there's no 'known' runtimes for GCF.
    • Does anyone know of docker images that simulate the runtime environment of GCF?
    • (I've found https://github.com/GoogleCloudPlatform/python-runtime but it's for AppEngine and is quite old, and https://cloud.google.com/functions/docs/concepts/python-runtime is very cagey about Python patch versions, let alone GLibc/manylinux tags!)
  • This changes the interaction between the runtime and complete_platforms field:
    • passing both is deprecated, and the behaviour changes too (runtime is now totally ignored, but, per point 3 of the motivation above, this would fail anyway)
    • passing complete_platforms=[] is now permitted, and, I hope, means the PEX calls will use the ambient interpreter, e.g. if running in a compatible docker image
  • I haven't written explicit tests for the inference behaviour yet, as I didn't want to go too deep down that path before validating that this is sensible
  • I've only implemented this for layout = "zip", as layout = "lambdex" will be removed soon.
  • (Once we have this, I think we can even do one step better: infer an appropriate runtime from interpreter constraints (e.g. if a repo has constraints that cover only one major version, like ==3.10.*, infer runtime="python3.10"), so that a minimal FaaS target can be python_aws_lambda_function(name="foo", handler="./foo.py:handler").)

Fixes #18195

+2608 -27

0 comment

15 changed files

pr created time in 2 hours

create barnchhuonw/pants

branch : feature/18195-auto-complete-platforms

created branch time in 3 hours

pull request commentpantsbuild/pants

Handle `from foo import *` wildcard imports in Rust dep inference parser

I've pushed a few changes, including a defensive one to hopefully make problems like this more obvious in future: make sure there's always some sort of import inserted every time a from .. import .. statement is visited, because inserting nothing is "obviously" wrong. In particular, it's particularly dangerous that inference failed silently here, and I only identified it because tests failed when running 2.17.0rc0 in our CI, rather than getting noisy dep inference failure warnings when running simple commands locally.

You're going to get bit by https://github.com/pantsbuild/pants/issues/18961 if you haven't already.

Thanks, I got bit by that for testing #19173 😅

(On that note, I have a suspicion that --no-local-cache might not work for this? Even with that flag I think I was getting cached results)

I was thinking of computing a hash of the files during the build step and using that. Otherwise we need to manually bump the (not-yet-added) version.

Thoughts?

Either seems fine to me, both have trade-offs:

  • manual version: 'precise' (e.g. doesn't change for no-functionality-change edits, like reformatting or adding comments), but potential to forget to change
  • hash: potentially awkward to correctly hash the right things (all relevant files and all dependency versions, including down to tree sitter (relates to #8445)), and changes spuriously more often

On balance, I guess hashing is probably better for now: this runs fast enough that (for most users) rerunning when upgrading pants versions is probably unnoticeable compared to all the other work that happens?

huonw

comment created time in 3 hours

PullRequestReviewEvent

push eventhuonw/pants

Huon Wilson

commit sha 7bb695a5f4a64c766e61b3c43570028bbb964297

Review: insert_import doc comment

view details

Huon Wilson

commit sha 48aef6f147564493a9a61a9e7e92fd1765d54c6e

Adjust to avoid early returns

view details

Huon Wilson

commit sha f182199c10a05c3481d97efd40c7eef8b21f38d5

Ensure we don't ever totally ignore an import statement

view details

push time in 4 hours

PullRequestReviewEvent

Pull request review commentpantsbuild/pants

Apply taplo to the repository

 org = "pantsbuild" # CI runs occasionally hit the 30 minute mark. token_expiration_threshold = 40 ci_env_variables = [-  "GITHUB_ACTIONS", "GITHUB_RUN_ID", "GITHUB_REF", "GITHUB_EVENT_NAME", "GITHUB_SHA", "GITHUB_REPOSITORY",-  "GITHUB_WORKFLOW","GITHUB_JOB",  # temporary, for debugging issues w/ restricted tokens.+  "GITHUB_ACTIONS",+  "GITHUB_RUN_ID",+  "GITHUB_REF",+  "GITHUB_EVENT_NAME",+  "GITHUB_SHA",+  "GITHUB_REPOSITORY",+  "GITHUB_WORKFLOW",+  "GITHUB_JOB",        # temporary, for debugging issues w/ restricted tokens.

I would personally consider turning off this alignment completely: it means adding or removing a long option is more likely to lead to spurious diffs on other lines, due to needing to adjust their alignment.

(I'm also not silly enough to dive down a syntax bikeshed, though: having auto formatting in some form is better than getting mired in a config argument!)

bryanwweber

comment created time in 6 hours

push eventhuonw/pants

Huon Wilson

commit sha e387a8c2b8b9480130d82ea18183dea0e4122b77

Rewrite to 'base' / 'imported' terminology

view details

Huon Wilson

commit sha cba6797f528002b881151db8c7a77eeb5aa20470

Failing tests

view details

Huon Wilson

commit sha 079ee952a0bc75dc110225ecf8fd60de00d63f1e

Handle `from ... import *` wildcard imports

view details

push time in 19 hours

PR opened pantsbuild/pants

Handle `from foo import *` wildcard imports in Rust dep inference parser needs-cherrypick category:internal

This fixes #19248 by implementing explicit handling for * wildcard imports in the Rust-based Python dependency inference parser.

The commits are individually reviewable:

  1. switching how the insert_import arguments are consumed from the syntax tree, for from ... import ... statements in particular:
    • before: name and module_name correspond to import $name, "$name", from $module_name import $name
    • after: base and imported correspond to import $base, "$base", from $base import $imported
    • This is in particular changing whether the from ... part is the optional (before) or not (after).
    • The motivation is that there's more functional similarities between the from ... part and a plain import ... statement, than between the import ... part and a plain import ... statement, despite the superficial similarities of it! (from foo import bar is a little like import foo as __secret; bar = __secret.bar.)
  2. Add some tests that fail
  3. Fix the bug
+89 -25

0 comment

2 changed files

pr created time in 19 hours

create barnchhuonw/pants

branch : bugfix/19248-globs

created branch time in 19 hours

delete branch huonw/fastapi

delete branch : clone-cache-conversion

delete time in 20 hours

issue openedpantsbuild/pants

`from ..foo import *` are silently ignored by Rust parser

Describe the bug

The new Rust parser doesn't seem to understand a 'plain' parent import, like from ..file1 import *. It does understand from ..file1 import func, though.

This reproducer constructs a directory structure like:

.
├── pants.toml
└── src
    └── a
        ├── BUILD
        ├── file1.py
        └── file2.py

where file2.py has from .file1 import *. It runs pants peek src/a/file2.py with both the python parser (which shows a dependency on src/a/file1.py) and with the Rust parser (which doesn't):

cd $(mktemp -d)

cat > pants.toml <<EOF
[GLOBAL]
pants_version = "2.17.0rc0"

backend_packages = ["pants.backend.python"]

[python]
interpreter_constraints = [">=3.8"]

[python-infer]
use_rust_parser = false
EOF

# set up the file structure:
mkdir -p src/a
touch src/a/file1.py
echo "from .file1 import *" > src/a/file2.py

echo "python_sources()" > src/a/BUILD

tree .

# OK: with Python parser `"dependencies": ["src/a/file1.py"]`
pants peek src/a/file2.py

# flip to the rust parser
sed -i '' 's/use_rust_parser = false/use_rust_parser = true/' pants.toml

# BUG: with Rust parser `"dependencies": []`
pants peek src/a/file2.py

Pants version 2.17.0rc0

OS macOS

Additional info #19173

created time in a day

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentpantsbuild/pants

WIP: Modernize the Cherry-Picker script

+class CherryPickHelper {+  constructor({ octokit, context, core }) {+    this.octokit = octokit;+    this.context = context;+    this.core = core;+    this.pull_number =+      this.context.issue.number || this.context.payload.inputs.PR_number;+  }++  get #issue_context() {+    return {+      ...this.context.repo,+      // NB: In GitHub nomenclature, pull requests are (also) issues.+      issue_number: this.pull_number,+    };+  }++  get #pull_context() {+    return {+      ...this.context.repo,+      pull_number: this.pull_number,+    };+  }++  get #run_link() {+    return `:robot: [Beep Boop here's my run link](${this.context.serverUrl}/${this.context.repo.owner}/${this.context.repo.repo}/actions/runs/${this.context.runId}/jobs/${this.context.job})`;+  }++  #get_branch_name(milestone_title) {+    return `cherry-pick-${this.pull_number}-to-${milestone_title}`;+  }++  async #add_failed_label() {+    await this.octokit.rest.issues.addLabels({+      ...this.#issue_context,+      labels: ["auto-cherry-picking-failed"],+    });+  }++  async #add_comment(body) {+    await this.octokit.rest.issues.createComment({+      ...this.#issue_context,+      body,+    });+  }++  async #get_relevant_milestones(milestone_title) {+    const semver = require("semver");+    const { data: all_milestones } =+      await this.octokit.rest.issues.listMilestones({+        ...this.#issue_context,+        state: "open",+      });+    const sorted_milestones = all_milestones+      .map((milestone) => milestone.title)+      .filter((title) => title.startsWith("2.") && title.endsWith(".x"))+      .sort((a, b) => semver.compare(semver.coerce(a), semver.coerce(b)));+    const relevant_milestones = sorted_milestones.slice(+      sorted_milestones.indexOf(milestone_title)+    );+    return relevant_milestones;+  }++  async get_prereqs() {+    const { data: pull } = await this.octokit.rest.pulls.get({+      ...this.#pull_context,+    });++    if (pull.milestone == null) {+      const { data: workflows } =+        // NB: GitHub doesn't give you the URL to the workflow, or the filename, when running a workflow.+        await this.octokit.rest.actions.listRepoWorkflows({+          ...this.context.repo,+        });+      const workflow_url = workflows.workflows.filter(+        (workflow) => workflow.name === this.context.workflow+      )[0].url;++      await this.#add_failed_label();+      await this.#add_comment(+        `I was unable to cherry-pick this PR; the milestone seems to be missing.++Please add the milestone to the PR and re-run the [Auto Cherry-Picker job](${workflow_url}) using the "Run workflow" button.

FWIW my second act was going to be a new GHA check (extending the label check) to check for a milestone if there's a CherryPick label

👍

Even with that initial checker (which sounds good), I think it'd be good to have the script still handle the no milestone case. In particular, it might be easy for the script to 'succeed' at doing nothing, if a PR ended up with no milestone. This might mean it clears out the "needs-cherrypick" label without actually doing any cherry picking.

For instance, this sequence seems plausible (maybe not with the current code, but maybe with a small tweak in future):

  • someone adds a milestone before CI runs and it passes, but it's removed by the time the PR merged (either accidentally or on purpose)
  • cherry picker runs, and ends up with an empty set of milestones
  • the "do the appropriate PRs exist" check is trivially true (there's no milestones, so having no PRs is correct ✅ ), and so the script falls through to removing the label
thejcannon

comment created time in a day

PullRequestReviewEvent

Pull request review commentpantsbuild/pants

WIP: Modernize the Cherry-Picker script

+class CherryPickHelper {+  constructor({ octokit, context, core }) {+    this.octokit = octokit;+    this.context = context;+    this.core = core;+    this.pull_number =+      this.context.issue.number || this.context.payload.inputs.PR_number;+  }++  get #issue_context() {+    return {+      ...this.context.repo,+      // NB: In GitHub nomenclature, pull requests are (also) issues.+      issue_number: this.pull_number,+    };+  }++  get #pull_context() {+    return {+      ...this.context.repo,+      pull_number: this.pull_number,+    };+  }++  get #run_link() {+    return `:robot: [Beep Boop here's my run link](${this.context.serverUrl}/${this.context.repo.owner}/${this.context.repo.repo}/actions/runs/${this.context.runId}/jobs/${this.context.job})`;+  }++  #get_branch_name(milestone_title) {+    return `cherry-pick-${this.pull_number}-to-${milestone_title}`;+  }++  async #add_failed_label() {+    await this.octokit.rest.issues.addLabels({+      ...this.#issue_context,+      labels: ["auto-cherry-picking-failed"],+    });+  }++  async #add_comment(body) {+    await this.octokit.rest.issues.createComment({+      ...this.#issue_context,+      body,+    });+  }++  async #get_relevant_milestones(milestone_title) {+    const semver = require("semver");+    const { data: all_milestones } =+      await this.octokit.rest.issues.listMilestones({+        ...this.#issue_context,+        state: "open",+      });+    const sorted_milestones = all_milestones+      .map((milestone) => milestone.title)+      .filter((title) => title.startsWith("2.") && title.endsWith(".x"))+      .sort((a, b) => semver.compare(semver.coerce(a), semver.coerce(b)));+    const relevant_milestones = sorted_milestones.slice(+      sorted_milestones.indexOf(milestone_title)+    );+    return relevant_milestones;+  }++  async get_prereqs() {+    const { data: pull } = await this.octokit.rest.pulls.get({+      ...this.#pull_context,+    });++    if (pull.milestone == null) {+      const { data: workflows } =+        // NB: GitHub doesn't give you the URL to the workflow, or the filename, when running a workflow.+        await this.octokit.rest.actions.listRepoWorkflows({+          ...this.context.repo,+        });+      const workflow_url = workflows.workflows.filter(+        (workflow) => workflow.name === this.context.workflow+      )[0].url;++      await this.#add_failed_label();+      await this.#add_comment(+        `I was unable to cherry-pick this PR; the milestone seems to be missing.++Please add the milestone to the PR and re-run the [Auto Cherry-Picker job](${workflow_url}) using the "Run workflow" button.++${this.#run_link}`+      );+      this.core.setFailed(`PR missing milestone.`);+      return null;+    }++    const milestones = await this.#get_relevant_milestones(+      pull.milestone.title+    );+    return {+      pr_num: this.pull_number,+      merge_commit: pull.merge_commit_sha,+      milestones: milestones,+    };+  }++  async cherry_pick_failed(merge_commit_sha, milestone_title) {+    this.#add_failed_label();+    await this.#add_comment(+      `I was unable to cherry-pick this PR to ${milestone_title}, likely due to merge-conflicts.++To resolve:+1. (Ensure your git working directory is clean)+2. Run the following script to reproduce the merge-conflicts:+    \`\`\`bash+    git checkout https://github.com/pantsbuild/pants main \\+      && git pull \\

Ah, yeah, that'd work, as long as we're good about always cherry-picking any changes.

thejcannon

comment created time in a day

PullRequestReviewEvent

issue closedpantsbuild/pants

"cannot infer owners" warning for `from .. import foo` with Rust parser

Describe the bug

The new Rust parser doesn't seem to understand a 'plain' parent import, like from .. import foo. It does understand from ..foo import bar, though.

For instance, the following reproducer sets up a file tree like the following, with file2 containing from .. import file1.

.
├── pants.toml
└── src
    └── a
        ├── BUILD
        ├── b
        │   ├── BUILD
        │   └── file2.py
        └── file1.py

Running it with the Rust parser prints the following warning, and indeed, the peek output doesn't include a dependency from file2 to file1:

20:32:17.51 [WARN] Pants cannot infer owners for the following imports in the target src/a/b/file2.py:

  * ...file1 (line: 1)

If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the import line. Otherwise, see https://www.pantsbuild.org/v2.17/docs/troubleshooting#import-errors-and-missing-dependencies for common problems.

Reproducer:

cd $(mktemp -d)

cat > pants.toml <<EOF
[GLOBAL]
pants_version = "2.17.0a1"

backend_packages = [
  "pants.backend.python",
]

[python]
interpreter_constraints = [">=3.8"]

[python-infer]
use_rust_parser = false
EOF

# set up the nested file structure:
mkdir -p src/a/b
touch src/a/file1.py
echo "python_sources()" > src/a/BUILD

echo "from .. import file1" > src/a/b/file2.py
echo "python_sources()" > src/a/b/BUILD

# confirm the layout
tree .

# OK: with Python parser `"dependencies": ["src/a/file1.py"]`
pants peek src/a/b/file2.py

# flip to the rust parser
sed -i '' 's/use_rust_parser = false/use_rust_parser = true/' pants.toml

# BUG: with Rust parser `"dependencies": []`
pants peek src/a/b/file2.py
# "[WARN] Pants cannot infer owners for the following imports in the target src/a/b/file2.py:"

Pants version 2.17.0a1

OS macOS

Additional info N/A

closed time in 2 days

huonw
more