Github
zenml.integrations.github
Initialization of the GitHub ZenML integration.
Attributes
GITHUB = 'github'
module-attribute
GITHUB_EVENT_FLAVOR = 'github'
module-attribute
Classes
BasePluginFlavor
Bases: ABC
Base Class for all PluginFlavors.
Functions
get_flavor_response_model(hydrate: bool) -> BasePluginFlavorResponse[Any, Any, Any]
abstractmethod
classmethod
Convert the Flavor into a Response Model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hydrate
|
bool
|
Whether the model should be hydrated. |
required |
Source code in src/zenml/plugins/base_plugin_flavor.py
79 80 81 82 83 84 85 86 87 88 |
|
GitHubIntegration
Bases: Integration
Definition of GitHub integration for ZenML.
Functions
plugin_flavors() -> List[Type[BasePluginFlavor]]
classmethod
Declare the event flavors for the github integration.
Returns:
Type | Description |
---|---|
List[Type[BasePluginFlavor]]
|
List of stack component flavors for this integration. |
Source code in src/zenml/integrations/github/__init__.py
31 32 33 34 35 36 37 38 39 40 |
|
Integration
Base class for integration in ZenML.
Functions
activate() -> None
classmethod
Abstract method to activate the integration.
Source code in src/zenml/integrations/integration.py
175 176 177 |
|
check_installation() -> bool
classmethod
Method to check whether the required packages are installed.
Returns:
Type | Description |
---|---|
bool
|
True if all required packages are installed, False otherwise. |
Source code in src/zenml/integrations/integration.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
flavors() -> List[Type[Flavor]]
classmethod
Abstract method to declare new stack component flavors.
Returns:
Type | Description |
---|---|
List[Type[Flavor]]
|
A list of new stack component flavors. |
Source code in src/zenml/integrations/integration.py
179 180 181 182 183 184 185 186 |
|
get_requirements(target_os: Optional[str] = None, python_version: Optional[str] = None) -> List[str]
classmethod
Method to get the requirements for the integration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_os
|
Optional[str]
|
The target operating system to get the requirements for. |
None
|
python_version
|
Optional[str]
|
The Python version to use for the requirements. |
None
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of requirements. |
Source code in src/zenml/integrations/integration.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
|
get_uninstall_requirements(target_os: Optional[str] = None) -> List[str]
classmethod
Method to get the uninstall requirements for the integration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_os
|
Optional[str]
|
The target operating system to get the requirements for. |
None
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of requirements. |
Source code in src/zenml/integrations/integration.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
plugin_flavors() -> List[Type[BasePluginFlavor]]
classmethod
Abstract method to declare new plugin flavors.
Returns:
Type | Description |
---|---|
List[Type[BasePluginFlavor]]
|
A list of new plugin flavors. |
Source code in src/zenml/integrations/integration.py
188 189 190 191 192 193 194 195 |
|
Modules
code_repositories
Initialization of the ZenML GitHub code repository.
Classes
GitHubCodeRepository(id: UUID, name: str, config: Dict[str, Any])
Bases: BaseCodeRepository
GitHub code repository.
Source code in src/zenml/code_repositories/base_code_repository.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
config: GitHubCodeRepositoryConfig
property
Returns the GitHubCodeRepositoryConfig
config.
Returns:
Type | Description |
---|---|
GitHubCodeRepositoryConfig
|
The configuration. |
github_repo: Repository
property
The GitHub repository object from the GitHub API.
Returns:
Type | Description |
---|---|
Repository
|
The GitHub repository. |
Raises:
Type | Description |
---|---|
RuntimeError
|
If the repository cannot be found. |
check_github_repo_public(owner: str, repo: str) -> None
Checks if a GitHub repository is public.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
owner
|
str
|
The owner of the repository. |
required |
repo
|
str
|
The name of the repository. |
required |
Raises:
Type | Description |
---|---|
RuntimeError
|
If the repository is not public. |
Source code in src/zenml/integrations/github/code_repositories/github_code_repository.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
check_remote_url(url: str) -> bool
Checks whether the remote url matches the code repository.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
The remote url. |
required |
Returns:
Type | Description |
---|---|
bool
|
Whether the remote url is correct. |
Source code in src/zenml/integrations/github/code_repositories/github_code_repository.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
|
download_files(commit: str, directory: str, repo_sub_directory: Optional[str]) -> None
Downloads files from a commit to a local directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
commit
|
str
|
The commit to download. |
required |
directory
|
str
|
The directory to download to. |
required |
repo_sub_directory
|
Optional[str]
|
The sub directory to download from. |
required |
Raises:
Type | Description |
---|---|
RuntimeError
|
If the repository sub directory is invalid. |
Source code in src/zenml/integrations/github/code_repositories/github_code_repository.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
|
get_local_context(path: str) -> Optional[LocalRepositoryContext]
Gets the local repository context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The path to the local repository. |
required |
Returns:
Type | Description |
---|---|
Optional[LocalRepositoryContext]
|
The local repository context. |
Source code in src/zenml/integrations/github/code_repositories/github_code_repository.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
|
login() -> None
Logs in to GitHub using the token provided in the config.
Raises:
Type | Description |
---|---|
RuntimeError
|
If the login fails. |
Source code in src/zenml/integrations/github/code_repositories/github_code_repository.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
validate_config(config: Dict[str, Any]) -> None
classmethod
Validate the code repository config.
This method should check that the config/credentials are valid and the configured repository exists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
Dict[str, Any]
|
The configuration. |
required |
Source code in src/zenml/integrations/github/code_repositories/github_code_repository.py
67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
Modules
github_code_repository
GitHub code repository.
GitHubCodeRepository(id: UUID, name: str, config: Dict[str, Any])
Bases: BaseCodeRepository
GitHub code repository.
Source code in src/zenml/code_repositories/base_code_repository.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
config: GitHubCodeRepositoryConfig
property
Returns the GitHubCodeRepositoryConfig
config.
Returns:
Type | Description |
---|---|
GitHubCodeRepositoryConfig
|
The configuration. |
github_repo: Repository
property
The GitHub repository object from the GitHub API.
Returns:
Type | Description |
---|---|
Repository
|
The GitHub repository. |
Raises:
Type | Description |
---|---|
RuntimeError
|
If the repository cannot be found. |
check_github_repo_public(owner: str, repo: str) -> None
Checks if a GitHub repository is public.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
owner
|
str
|
The owner of the repository. |
required |
repo
|
str
|
The name of the repository. |
required |
Raises:
Type | Description |
---|---|
RuntimeError
|
If the repository is not public. |
Source code in src/zenml/integrations/github/code_repositories/github_code_repository.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
check_remote_url(url: str) -> bool
Checks whether the remote url matches the code repository.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
The remote url. |
required |
Returns:
Type | Description |
---|---|
bool
|
Whether the remote url is correct. |
Source code in src/zenml/integrations/github/code_repositories/github_code_repository.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
|
download_files(commit: str, directory: str, repo_sub_directory: Optional[str]) -> None
Downloads files from a commit to a local directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
commit
|
str
|
The commit to download. |
required |
directory
|
str
|
The directory to download to. |
required |
repo_sub_directory
|
Optional[str]
|
The sub directory to download from. |
required |
Raises:
Type | Description |
---|---|
RuntimeError
|
If the repository sub directory is invalid. |
Source code in src/zenml/integrations/github/code_repositories/github_code_repository.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
|
get_local_context(path: str) -> Optional[LocalRepositoryContext]
Gets the local repository context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The path to the local repository. |
required |
Returns:
Type | Description |
---|---|
Optional[LocalRepositoryContext]
|
The local repository context. |
Source code in src/zenml/integrations/github/code_repositories/github_code_repository.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
|
login() -> None
Logs in to GitHub using the token provided in the config.
Raises:
Type | Description |
---|---|
RuntimeError
|
If the login fails. |
Source code in src/zenml/integrations/github/code_repositories/github_code_repository.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
validate_config(config: Dict[str, Any]) -> None
classmethod
Validate the code repository config.
This method should check that the config/credentials are valid and the configured repository exists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
Dict[str, Any]
|
The configuration. |
required |
Source code in src/zenml/integrations/github/code_repositories/github_code_repository.py
67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
GitHubCodeRepositoryConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseCodeRepositoryConfig
Config for GitHub code repositories.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_url
|
The GitHub API URL. |
required | |
owner
|
The owner of the repository. |
required | |
repository
|
The name of the repository. |
required | |
host
|
The host of the repository. |
required | |
token
|
The token to access the repository. |
required |
Source code in src/zenml/config/secret_reference_mixin.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
plugins
Github event flavors.
Classes
GithubWebhookEventSourceFlavor
Modules
event_sources
github_webhook_event_source
Implementation of the github webhook event source.
Commit
Bases: BaseModel
Github Event.
GithubEvent
Bases: BaseEvent
Push Event from Github.
branch: Optional[str]
property
The branch the event happened on.
Returns:
Type | Description |
---|---|
Optional[str]
|
The branch name. |
event_type: Union[GithubEventType, str]
property
The type of github event.
Returns:
Type | Description |
---|---|
Union[GithubEventType, str]
|
The type of the event. |
GithubEventType
GithubWebhookEventFilterConfiguration
Bases: WebhookEventFilterConfig
Configuration for github event filters.
event_matches_filter(event: BaseEvent) -> bool
Checks the filter against the inbound event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event
|
BaseEvent
|
The incoming event |
required |
Returns:
Type | Description |
---|---|
bool
|
Whether the event matches the filter |
Source code in src/zenml/integrations/github/plugins/event_sources/github_webhook_event_source.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
|
GithubWebhookEventSourceConfiguration
GithubWebhookEventSourceHandler(event_hub: Optional[BaseEventHub] = None)
Bases: BaseWebhookEventSourceHandler
Handler for all github events.
Source code in src/zenml/event_sources/base_event_source.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
config_class: Type[GithubWebhookEventSourceConfiguration]
property
Returns the webhook event source configuration class.
Returns:
Type | Description |
---|---|
Type[GithubWebhookEventSourceConfiguration]
|
The configuration. |
filter_class: Type[GithubWebhookEventFilterConfiguration]
property
Returns the webhook event filter configuration class.
Returns:
Type | Description |
---|---|
Type[GithubWebhookEventFilterConfiguration]
|
The event filter configuration class. |
flavor_class: Type[BaseWebhookEventSourceFlavor]
property
Returns the flavor class of the plugin.
Returns:
Type | Description |
---|---|
Type[BaseWebhookEventSourceFlavor]
|
The flavor class of the plugin. |
PullRequest
Bases: BaseModel
Github Pull Request.
Repository
Bases: BaseModel
Github Repository.
Tag
Bases: BaseModel
Github Tag.
User
Bases: BaseModel
Github User.
github_webhook_event_source_flavor
Github webhook event source flavor.
GithubWebhookEventSourceFlavor