I would like to add an existing git repository I work on to my server code.
Background:
There is some python code I want to run on the server side of my Anvil website. This code is managed on my local computer. It would be great if I could git clone this repository of mine on to my anvil server.
I would then want to periodically update the server code (using the git pull command)
There seems to be no mentioning of cloning into the server code in the Anvil documentation (Only how to clone the existing code to a remote device)
How do I do this?
Clone the Anvil app to your local machine (or pull from Anvil to update it)
Make changes to the repo on your local machine (adding files, etc)
Commit and push those changes back to Anvil
Depending on what you’re doing in #2, you may or may not have any luck. I’m sure there are things you could do that would break the Anvil app, just as there are things you could do that would not get you what you wanted. But at least you could always revert to the previous commit and push to Anvil to get out of trouble.
If you’re talking about embedding another repository inside the Anvil app’s repository, I’m sure there are ways of doing that in git as well. They’d be done in the #2 step above. That’s beyond my git knowledge, though.
In this question there are considerations that may be helpful.
EDIT
I don’t know what happens (because I don’t own that repository and I haven’t tested with a repository I own) when the master has a new commit, but has no new version.
I know Anvil caches the environments, so it doesn’t need to rebuild them every time you use them, but I don’t know any details about the caching.
I assume the key for the caching is requirements.txt, so any changes to requirements.txt will trigger the creation (or retrieval from cache) of the new environment. If this is the case, then using the master branch may cause the environment to be built with whatever master is at the time the environment is built and never be updated. And if this is the case, I wouldn’t know how to trigger a new update when master changes.
So, if you want to work with your own repository, you may need to create a new package version, then update requirements.txt in Anvil every time you change your repository. Maybe.
You can also specify a particular commit in your requirements – eg git+https://github.com/owner/repo@41b95ec – which will cause a rebuild with the exact version you specify!
If the text in requirements.txt doesn’t change, it doesn’t rebuild, and requirements.txt only changes when the user goes through the app settings, so there is never going to be an automatic rebuild.
Good!
If the user goes through the settings and changes the commit id or branch name or version, then the rebuild is triggered.
This means that using the branch name in requirements.txt, installs the branch the way it was at installation time and doesn’t automatically update when the branch is updated.
This behavior may seem to create inconsistencies, but it’s identical to what happens with custom environments managed locally on our computers.
Thanks for all the replies
Some things you mentioned don’t make sense to me (I would love you to dumb it down a little bit)
When you say package, do you mean my repository? My repository is basically a folder with a bunch of python scripts in it
I have a repository that I edit–>commit–>push periodically. What do you mean by “has no version”?
I currently don’t have a requirements.txt file in my Anvil app or my personal repository. Do you recommend I add one with the line you specified?
To conclude:
I feel a lot of important information has been detailed in this post but I am still not able to understand how I can add my own repository to my Anvil app and push changes when made.
OK
I’m currently giving up on being able to update my repository by git pull into my Anvil app
It seems that any module I add to my server code I cannot run
Trying to simplify my issue:
Lets say I have added a .py script of my own to my server code. The name of the file is MeshCreator.py
When attempting to run the code I receive the following error: