Closed virtuald closed 2 years ago
I like the idea of this, especially passing things like username and hostname! Its always important to know who to blame. Im glad you jumped on this, a deploy.json would be a very handy way to do this.
Where would the logic of this hook best sit?
Ive used gitpython
in the past for interacting with git repos via python but is there a simpler way that may depend on less extra libraries if we just want to get the hash and maybe a --dirty flag?
I think i found where this belongs: https://github.com/robotpy/pyfrc/blob/2022/pyfrc/mains/cli_deploy.py
Should we make a custom hooks system or just implement this single hook?
I haven't really thought through the requirements at this point. I think initially
If we wanted the user to be able to customize the json, we could define the following method in the robot:
class MyRobot(wpilib.TimedRobot):
@staticmethod
def deploy_hook(data):
data["something"] = something
If we did that... we could add a deploy_data
method to the robot instance if the user wanted to access it? Maybe that's a bit much though. Should think about how this would actually be used.
I like the idea of doing something custom with a similar format to how physics.py works, where its inert and says physics is not enabled if the file does not exist, but runs physics sim when it is present.
perhaps a similar system with a hooks.py? excecuting a few methods like deploy_hook()
and test_hook()
? Code to be run on the host doing the developing, seperate from robotinit and stuff that is meant to be for the robot
Could we make a build_info.json
purely in deploy, never saving it to disk but passing it over sftp? it would keep it from showing up on the dev's machine. Though if you're using git to manage your robot, you'ld prolly add the json to your gitignore and saving it locally may not be a hassle.
If we went the json route, I have a strong preference for it only existing on the robot. We already make a temporary directory to copy data over, see https://github.com/robotpy/pyfrc/blob/c94b21b22de6f654ab866878fe8e1cd9ebef1f81/pyfrc/mains/cli_deploy.py#L388
If we went the json route, I have a strong preference for it only existing on the robot. We already make a temporary directory to copy data over, see
Oh, this is perfect. I 100% agree, i can modify #196 to reflect this.
Not everyone uses git so it may be nice if it just ommits a git-revision rather than not inluding the other vars at all, that way code managed by other source control engines or not managed at all can still utilize the other values like hostname and build date that may be more helpful
Heh, I have a hack to include the git branch and commit hash in a deploy in my team's robot code. This gets called at the module level in our robot.py. https://github.com/thedropbears/pyrapidreact/blob/main/utilities/git.py
It would definitely be a requirement to not fail if it wasn't a git repo.
@auscompgeek you've been holding out on us!
Super cool @auscompgeek! does this require transfering the .git
to the robot though?
does this require transfering the
.git
to the robot though?
Nope! There's a few assumptions made here:
.git
is not present on the robot.Interesting, so if its possible to run stuff like this at the module level on the dev laptop to generate artifacts for the bot, them #195 is not needed :3 ill still work on #196
Fixed in #196
I'm thinking maybe a hook of some kind?
Or, we could auto-generate a JSON file with useful information to
deploy.json
.And print it out during robot startup if
deploy.json
is present?