Closed otherjon closed 8 months ago
e.g. to determine the Git commit hash and branch and write them to files to be deployed to the RoboRIO.
We already gather git metadata to stamp the deploy, which gets printed at robot start. See https://robotpy.readthedocs.io/en/stable/dev/deploy.html#deploy-artifacts
Running other arbitrary code at deploy time is also already possible, as your robot code is the entry point for deploying. This is how I stamped deploys with git metadata before we baked it into the deploy process as outlined above.
Do you have a use-case which isn't well suited by the above? I'm not sure this complexity makes sense here in this form.
Thanks for the pointer to the deploy artifact information. I hadn't looked at the developer documentation earlier because I hadn't considered myself a robotpy developer until now. Since the Git info was my primary motivation, I'll cancel the pull request.
While obviously I run "robot.py deploy" in order to deploy, I'm at a loss to explain how I'd add code to my robot.py to execute a pre-release script. Do you have a pointer to info about that, or the name a method I should override?
It's also documented in the user docs at https://robotpy.readthedocs.io/projects/robotpy/en/latest/wpilib.deployinfo.html, but... it wasn't documented in prior years even though it was there if you looked for it.
Strictly speaking, you could put whatever arbitrary code you want in the if __name__ == "__main__":
block of your code, including something that checks sys.argv to see if deploy is occurring.
Hi robotpy team,
I was wondering how you folks might feel about allowing a pre-release script to be specified on the command line when deploying code to a RoboRIO.
A pre-deploy script can serve the same purpose as Gradle tasks, e.g. to determine the Git commit hash and branch and write them to files to be deployed to the RoboRIO. (See this WPILib page for the Java equivalent.)
In this draft implementation, pre-deploy scripts must be written in Python (this allows equivalent invocation on Windows or Linux), and will receive a command-line argument of --robot_path <path/to/dir/of/robot.py>
Sample predeploy script: available here
I see that you're in the process of moving deploy functionality from pyfrc to robot-installer, so I'm submitting my pull request as a commit on top of the robotpy-installer/add-deploy branch, but let me know if there's a better strategy.