Skip to content
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

Adds run support for deploy_jar targets #14352

Merged
merged 10 commits into from Feb 7, 2022

Conversation

chrisjrn
Copy link
Contributor

@chrisjrn chrisjrn commented Feb 3, 2022

This adds run support for deploy_jar targets. It works! Closes #14283, at least until war files are properly supported.

To make Scala binaries work, we now inject a dependency for the version of scala-library specified by --scala-version at compile time, whenever scala-library is not provided as a transitive dependency. This is a good-enough stop-gap in service of #14171.

There's one ugly caveat which I'm reserving for future work:

For tool support, Couriser downloads a JVM into an append-only cache for most JVM processes. Since InteractiveProcess does not support these, I've added RuntimeJdk__, which downloads a JDK into a Digest. The digest gets written into the temporary directory alongside the runnable artifacts. It's not ideal, but for now, it removes the JDK download process from the run process, and the JDK is only downloaded once per pantsd execution. It's probably ok for now. Being able to reuse the global append-only cache directories will be a better solution once we get there.

Christopher Neugebauer added 3 commits February 1, 2022 16:24
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@chrisjrn chrisjrn requested a review from stuhood February 3, 2022 21:13
@chrisjrn chrisjrn marked this pull request as draft February 3, 2022 21:13
Christopher Neugebauer added 4 commits February 4, 2022 09:45
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
…re-downloading JDKs

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
…ects

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@chrisjrn chrisjrn changed the title Add prototype run support for most deploy JARs Add Good Enough™ run support for deploy_jar targets Feb 4, 2022
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@chrisjrn chrisjrn marked this pull request as ready for review February 4, 2022 20:39
Copy link
Sponsor Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. We definitely have work to do on improving these APIs!

Comment on lines +82 to +87
if not any(
filename.startswith("org.scala-lang_scala-library_") for filename in all_dependency_jars
):
scala_library = await Get(ClasspathEntry, ScalaLibraryRequest(scala.version))
direct_dependency_classpath_entries += (scala_library,)

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we should probably consider this to be a workaround for #14171, rather than a fix. If this ends up needing another iteration, adding a TODO here pointing to that ticket would be good.

Comment on lines 29 to 30
This is a hideous stop-gap, which will no longer be necessary once `InteractiveProcess` supports
append-only caches.
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've expanded #13852 to cover this: if this goes through another iteration, it would be good to link there.

src/python/pants/jvm/jdk_rules.py Show resolved Hide resolved
@rule(level=LogLevel.DEBUG)
async def create_deploy_jar_run_request(
field_set: DeployJarFieldSet,
runtime_jvm: __RuntimeJvm,
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear how this ends up used... it's being captured, but I don't see anything re-writing the process execution to use it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +69 to +86
def prefixed(arg: str, prefixes: Iterable[str]) -> str:
if any(arg.startswith(prefix) for prefix in prefixes):
return f"{{chroot}}/{arg}"
else:
return arg

prefixes = (jdk_setup.bin_dir, jdk_setup.jdk_preparation_script, jdk_setup.java_home)
args = [prefixed(arg, prefixes) for arg in proc.argv]

env = {
**proc.env,
"PANTS_INTERNAL_ABSOLUTE_PREFIX": "{chroot}/",
}

# absolutify coursier cache envvars
for key in env:
if key.startswith("COURSIER"):
env[key] = prefixed(env[key], (jdk_setup.coursier.cache_dir,))
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Half of this is happening in the JDK support code, and the other half is happening here... it would be good for them to refer to one another with TODOs at least... possibly referencing #14386.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The complication here is the number of places where we're doing preprocessing of process arguments. This will definitely become easier once we no longer have to rewrite things

@stuhood
Copy link
Sponsor Member

stuhood commented Feb 7, 2022

Also, please adjust the PR title before landing.

@chrisjrn chrisjrn changed the title Add Good Enough™ run support for deploy_jar targets Adds run support for deploy_jar targets Feb 7, 2022
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@chrisjrn chrisjrn enabled auto-merge (squash) February 7, 2022 19:13
@chrisjrn chrisjrn merged commit 7c46c80 into pantsbuild:main Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to "run" JVM applications(java, scala)
2 participants