GitHub import
Import external packages for use in your code files
The fundamental purpose of GitHub import is to give files within your Baseten applications access to code managed separately on GitHub. This way, you don't have to copy in business logic or parsing scripts, just write simple wrappers to expose this code to your models and applications.
In order to use GitHub import, you must first enable the GitHub integration under the "Integrations" tab of the workspace settings. You must be a workspace admin to complete this action. View complete setup instructions:
Again, the purpose of GitHub import is bringing outside code into your Baseten apps. Think of it like installing packages from PyPi, but without the hassle of making your code pip installable. Instead, with GitHub import, you can add code from your GitHub to your application's Python environment and use it in your files.
Essentially, this means that you will be able to
import
code from your GitHub repositories into your Baseten applications.

To add a repository to your application, click the
+
next to "imported repositories" to open a browser with your linked GitHub repositories. If there are repos in your GitHub organization that aren’t available for import, you may need to grant the GitHub Baseten app access to those specific repos. Or if you just created the repository on GitHub and it is not showing up in the repository list, try refreshing the page to give the GitHub integration a change to reload your repositories.

When you select and import a repository, it may take a couple of minutes for the repository to be fully available. Once loaded, the you'll have access to the main/default branch of the repository in question.
When you add a repository to an application, it is only available for that application. Each application handles GitHub import separately.
Consider the following repository structure:
- my_modules/
- bar/
- bar.py
- foo/
- foo_utils.py
- foo_code.py
We want to import an object
FooUtils
from the file at my_modules/foo/foo_utils.py
to use in our main.py
code file in a Baseten application. We also want to import the Bar
object from my_modules/bar/bar.py
. This is accomplished with a standard import statement:from my_modules.foo.foo_utils import FooUtils
from my_modules.bar.bar import Bar
When you import a repository, we automatically add the root of the repository to your Python path. If your repository uses a subdirectory, for example
./my_modules
, within the repo as its Python root, you can customize the path like so:sys.path.append(os.path.join(context.path_for_imported_repo("my_github/my_project"), "my_modules"))
from foo.foo_utils import FooUtils
from bar.bar import Bar
The imported code will work exactly the same.
You can also access files from the repository via the
context
object.def print_imported_file_path(block_input, context, env):
print(context.path_for_imported_repo("my_github/my_project"))
return
Or, if you are im
When you make changes to code on GitHub, you'll need to pull those changes into your Baseten apps. This is handled with the detail view that expands from each imported repository.

Once changes are pulled, they must be published along with any other changes to the application. Adding, pulling, and deleting repositories gets reflected in the publish dialog.

You can delete repositories from your applications at any time. This change will be captured in the version history upon publishing the app. You can also disconnect the GitHub integration at any time.
If you delete the repository or an actively used commit on GitHub, but not on Baseten, this leads to somewhat unspecified behavior. Things may work temporarily, but as your application's Python environment is refreshed, it will be unable to clone the desired repository, and the repository will have to be manually removed before the application will function. So please do not delete repositories or in-use commits without first removing them from your Baseten application.
Integrating with GitHub and importing code into your Python environment gives rise to a few edge cases that are documented here in case you run into them.
We do not recursively clone git submodules.
At the moment, you cannot add a repo over 100 MB.
If your imported repository has PyPi requirements, you’ll have to manually add those to your project.
Last modified 3mo ago