@@ -48,9 +48,7 @@ def get_connector(
4848 )
4949
5050
51- # This non-public function includes the `docker_image` parameter, which is not exposed in the
52- # public API. See the `experimental` module for more info.
53- def _get_source ( # noqa: PLR0912, PLR0913, PLR0915 # Too complex
51+ def get_source ( # noqa: PLR0912, PLR0913, PLR0915 # Too complex
5452 name : str ,
5553 config : dict [str , Any ] | None = None ,
5654 * ,
@@ -87,13 +85,14 @@ def _get_source( # noqa: PLR0912, PLR0913, PLR0915 # Too complex
8785 (e.g. `my-image:latest`), the version will be appended as a tag (e.g. `my-image:0.1.0`).
8886 use_host_network: If set, along with docker_image, the connector will be executed using
8987 the host network. This is useful for connectors that need to access resources on
90- the host machine, such as a local database.
91- source_manifest: If set, the connector will be executed based on a declarative Yaml
92- source definition. This input can be `True` to auto-download the yaml spec, `dict`
93- to accept a Python dictionary as the manifest, `Path` to pull a manifest from
88+ the host machine, such as a local database. This parameter is ignored when
89+ `docker_image` is not set.
90+ source_manifest: If set, the connector will be executed based on a declarative YAML
91+ source definition. This input can be `True` to attempt to auto-download a YAML spec,
92+ `dict` to accept a Python dictionary as the manifest, `Path` to pull a manifest from
9493 the local file system, or `str` to pull the definition from a web URL.
9594 install_if_missing: Whether to install the connector if it is not available locally. This
96- parameter is ignored when local_executable is set.
95+ parameter is ignored when ` local_executable` or `source_manifest` are set.
9796 install_root: (Optional.) The root directory where the virtual environment will be
9897 created. If not provided, the current working directory will be used.
9998 """
@@ -206,13 +205,15 @@ def _get_source( # noqa: PLR0912, PLR0913, PLR0915 # Too complex
206205
207206 if source_manifest :
208207 if source_manifest is True :
209- http_url = (
208+ # Auto-set the manifest to a valid http address URL string
209+ source_manifest = (
210210 "https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-integrations"
211211 f"/connectors/{ name } /{ name .replace ('-' , '_' )} /manifest.yaml"
212212 )
213- print ("Installing connector from YAML manifest:" , http_url )
214- # Download the file
215- response = requests .get (http_url )
213+ if isinstance (source_manifest , str ):
214+ print ("Installing connector from YAML manifest:" , source_manifest )
215+ # Download the manifest file
216+ response = requests .get (url = source_manifest )
216217 response .raise_for_status () # Raise an exception if the download failed
217218
218219 if "class_name:" in response .text :
@@ -225,7 +226,7 @@ def _get_source( # noqa: PLR0912, PLR0913, PLR0915 # Too complex
225226 ),
226227 connector_name = name ,
227228 context = {
228- "manifest_url" : http_url ,
229+ "manifest_url" : source_manifest ,
229230 },
230231 )
231232
@@ -235,10 +236,14 @@ def _get_source( # noqa: PLR0912, PLR0913, PLR0915 # Too complex
235236 raise exc .AirbyteConnectorInstallationError (
236237 connector_name = name ,
237238 context = {
238- "manifest_url" : http_url ,
239+ "manifest_url" : source_manifest ,
239240 },
240241 ) from ex
241242
243+ if isinstance (source_manifest , Path ):
244+ source_manifest = cast (dict , yaml .safe_load (source_manifest .read_text ()))
245+
246+ # Source manifest is a dict at this point
242247 return Source (
243248 name = name ,
244249 config = config ,
@@ -280,54 +285,6 @@ def _get_source( # noqa: PLR0912, PLR0913, PLR0915 # Too complex
280285 raise
281286
282287
283- # This thin wrapper exposes only non-experimental functions.
284- # Aka, exclude the `docker_image` parameter for now.
285- # See the `experimental` module for more info.
286- def get_source (
287- name : str ,
288- config : dict [str , Any ] | None = None ,
289- * ,
290- streams : str | list [str ] | None = None ,
291- version : str | None = None ,
292- pip_url : str | None = None ,
293- local_executable : Path | str | None = None ,
294- install_if_missing : bool = True ,
295- install_root : Path | None = None ,
296- ) -> Source :
297- """Get a connector by name and version.
298-
299- Args:
300- name: connector name
301- config: connector config - if not provided, you need to set it later via the set_config
302- method.
303- streams: list of stream names to select for reading. If set to "*", all streams will be
304- selected. If not provided, you can set it later via the `select_streams()` or
305- `select_all_streams()` method.
306- version: connector version - if not provided, the currently installed version will be used.
307- If no version is installed, the latest available version will be used. The version can
308- also be set to "latest" to force the use of the latest available version.
309- pip_url: connector pip URL - if not provided, the pip url will be inferred from the
310- connector name.
311- local_executable: If set, the connector will be assumed to already be installed and will be
312- executed using this path or executable name. Otherwise, the connector will be installed
313- automatically in a virtual environment.
314- install_if_missing: Whether to install the connector if it is not available locally. This
315- parameter is ignored when local_executable is set.
316- install_root: (Optional.) The root directory where the virtual environment will be
317- created. If not provided, the current working directory will be used.
318- """
319- return _get_source (
320- name = name ,
321- config = config ,
322- streams = streams ,
323- version = version ,
324- pip_url = pip_url ,
325- local_executable = local_executable ,
326- install_if_missing = install_if_missing ,
327- install_root = install_root ,
328- )
329-
330-
331288__all__ = [
332289 "get_source" ,
333290]
0 commit comments