full-keyboard-92367
09/21/2021, 5:59 PMuvicorn module:app --reload
and programmatically uvicorn.run(app)
Unfortunately uvicorn discontinued usage of reload while programmatically running the server, so for reload feature to work(crucial in a development environment), the command has to be executed via shell.
I can't for the life of me figure out how to run a shell command or create a shell entrypoint with pants.
Also it would be great if you guys could provide point me to an actual real world project with pants for a reference to make sure I'm doing this correctly.modern-wolf-36228
09/21/2021, 9:05 PMmodern-wolf-36228
09/21/2021, 9:06 PMuvicorn.run("<module>:<app variable>", reload=True)
modern-wolf-36228
09/21/2021, 9:08 PMmodern-wolf-36228
09/21/2021, 9:12 PMscript
field is going to be introduced in the pex_binary
in the next release I guess, which you'll be able to use pex_binary(script="uvicorn")
polite-garden-50641
09/21/2021, 10:17 PMsalmon-planet-80683
09/21/2021, 10:17 PM./pants
as root to execute a test.
When I then try and do a ./pants
as <my own user> i, understandably, get something along the lines of
pants.pantsd.process_manager.ProcessManager.MetadataError: failed to purge metadata directory /ROOT_TO_MY_PANTS?PROJECT/.pids/26629ce97d56/pantsd: PermissionError(13, 'Permission denied')
Would there be a way for me to execute the purge_metadata_by_name
stuff as root so that it's not screwed up for my normal user?hundreds-father-404
09/22/2021, 6:45 AMPants handles dependencies with more precision than Python projects solely using workflows like requirements.txt or Poetry. Whereas normally you have a single virtual environment, Pants understands precisely which third-party dependencies each file in your project useshttps://www.pantsbuild.org/v2.7/docs/third-party-dependencies-rewrite. Feedback welcomed!
curved-television-6568
09/22/2021, 8:04 AMcurved-television-6568
09/22/2021, 8:04 AME Engine traceback:
E in select
E in pants.backend.docker.docker_build_context.create_docker_build_context
E in pants.backend.python.goals.package_pex_binary.package_pex_binary (src/python/proj/cli:bin)
E in pants.backend.python.util_rules.pex.create_pex
E in pants.backend.python.util_rules.pex.build_pex (src.python.proj.cli/bin.pex)
E in pants.engine.process.fallible_to_exec_result_or_raise
E Traceback (most recent call last):
E File "/private/var/folders/8j/c8jf_msj009947wyw82xvdkw0000gn/T/process-executionVc609f/src/python/pants/engine/process.py", line 258, in fallible_to_exec_result_or_raise
E raise ProcessExecutionFailure(
E pants.engine.process.ProcessExecutionFailure: Process 'Building src.python.proj.cli/bin.pex' failed with exit code 127.
E stdout:
E
E stderr:
E env: python: No such file or directory
curved-television-6568
09/22/2021, 8:04 AMdef test_packaged_pex_path(rule_runner: RuleRunner) -> None:
rule_runner.write_files(
{
"src/docker/BUILD": """docker_image(dependencies=["src/python/proj/cli:bin"])""",
"src/docker/Dockerfile": """FROM python""",
"src/python/proj/cli/BUILD": """pex_binary(name="bin", entry_point="main.py")""",
"src/python/proj/cli/main.py": """print("cli main")""",
}
)
assert_build_context(
rule_runner,
Address("src/docker", target_name="docker"),
expected_files=["src/docker/Dockerfile", "src.python.proj.cli/bin.pex"],
)
curved-television-6568
09/22/2021, 8:06 AMassert_build_context
requests this product from the rule runner:
context = rule_runner.request(
DockerBuildContext,
[
DockerBuildContextRequest(
address=address,
build_upstream_images=False,
)
],
)
And the rule runner has these rules:
return RuleRunner(
rules=[
*context_rules(),
*core_target_types_rules(),
*package_pex_binary.rules(),
*pex_from_targets.rules(),
*target_types_rules.rules(),
QueryRule(BuiltPackage, [PexBinaryFieldSet]),
QueryRule(DockerBuildContext, (DockerBuildContextRequest,)),
],
target_types=[DockerImage, Files, PexBinary],
)
where most of those rules are taken from the package_pex_binary_integration_test
.curved-television-6568
09/22/2021, 8:08 AMcurved-television-6568
09/22/2021, 8:09 AMcurved-television-6568
09/22/2021, 8:09 AMrule_runner.set_options([], env_inherit={"PATH", "PYENV_ROOT", "HOME"})
modern-wolf-36228
09/22/2021, 4:55 PMscript
field is already documented on 2.8.0.dev0
is already documented... but can I use it? 🤔loud-stone-83419
09/22/2021, 11:57 PMworried-salesclerk-37834
09/23/2021, 6:46 PMmodern-wolf-36228
09/23/2021, 7:09 PMwooden-stone-7624
09/24/2021, 5:59 AMpants.pantsd.process_manager.ProcessManager.Timeout: exceeded timeout of 60 seconds while waiting for pantsd to start
Could you please help me with this?curved-television-6568
09/24/2021, 7:37 AMexperimental_shell_command
target for v2.8. Your feedback would be most appreciated.
See this google doc: https://docs.google.com/document/d/1610tAFFCwlSR1WiclQCajwrks7fWaNEwQpfWEpkOUDo/edit?usp=sharingambitious-student-81104
09/24/2021, 3:48 PMbrash-baker-91190
09/24/2021, 3:53 PMbusy-vase-39202
09/24/2021, 8:17 PMworried-salesclerk-37834
09/24/2021, 8:27 PMpython_distribution
looks like it might be a way forward, but it looks like I'd have to make a separate distribution for the common library? It's relatively large, so I was hoping not to pull in the entire codebase.
Is there a way I can make a zip of a current python_library
that also pulls in all of its transitive dependency code?ambitious-student-81104
09/24/2021, 9:20 PMsources=["*.py"]
in my python_library
target in order for my pex_binary
in the same BUILD to run successfully, or else it would ImportError: No module named path.to.entry_point
; but in some other cases I don't need that source=["*.py"]
for things to work. What's the magic here?worried-salesclerk-37834
09/27/2021, 4:02 PMuser
09/27/2021, 4:09 PM./pants peek
. Check out the blog post and notes for more information:
https://t.co/aF5iedD70V
https://t.co/bgt9By8KxS
Twitterbrash-baker-91190
09/27/2021, 4:28 PMbrave-furniture-86963
09/27/2021, 7:11 PMrequirements.pex
and pytest_runner.pex
get built during ./pants test ::
?
I have defined 9 python_tests
targets in all in our repository, yet I’m seeing over 26 pytest_runner.pex
and over 31 requirements.pex
built (also these numbers change depending on how I structure my requirements.txt files).