Hello, Happy new year, I am very new to monorepo ...
# general
s
Hello, Happy new year, I am very new to monorepo build systems and I am currently testing how we can use pants to manage our Python monorepo. I have tried to get around a very simple issue: I have a Rest API service using FastAPI in a subfolder for my monorepo. The OpenAPI specification of that service is generated based on the implemented routers. I have an existing shell script that can do that and then use it to generate a Python SDK client package in a new subfolder and then install it in my virtual environment. Some tests in my Rest API service are then using this client to run tests again the service. I would like to implement this chain of dependencies using Pants and I am a bit lost between all the options. I tried two: 1. Create a custom target that would depends on the routers subpackage of my rest service, to trigger the generation of the
openapi.json
file and the Python SDK client. I used a code assistant to help but it got lost trying to create a plugin that never worked and I am not even sure it is the right way 2. Use a
shell_command
, I set it up like this:
Copy code
shell_command(
    command="./scripts/generate-python-sdk.sh", # my script to execute
    tools=["jq", "echo", "bash", "mkdir", "tar"],
    output_directories=["python-sdk"], # where the python client package should be generated
    execution_dependencies=[
        "//scripts:scripts0", # the folder containing my scripts
        ":reqs", # my python requirements
        "//myservice/api/routers:routers", # the subpackage where my routers are implemented
    ],
)
But I don't see anywhere how to use this command to go further, nor how to test it. Thanks a lot for your help
g
Make it a dep of a
run_shell_command
and run it
s
Thanks. When you say run it, you mean:
pants run $NAME_OF_MY_RUN_SHELL_COMMAND
?
g
yeah.
Copy code
run_shell_command(
 name="foo",
 dependencies=[":some_shell_command_name"],
 command="exit 0", # if you just want to run shell command
)

# then in shell

pants run path/to/folder:foo