Skip to content

Commit 89f6ecc

Browse files
Update internal tool install instructions to include pyenv, editable, and force (airbytehq#30858)
Co-authored-by: bnchrch <[email protected]> Co-authored-by: Prateek Mukhedkar <[email protected]>
1 parent 26787a8 commit 89f6ecc

File tree

12 files changed

+601
-430
lines changed

12 files changed

+601
-430
lines changed

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

airbyte-ci/.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

airbyte-ci/connectors/ci_credentials/README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,36 @@ This project requires Python 3.10 and pipx.
1111

1212
The recommended way to install `ci_credentials` is using pipx. This ensures the tool and its dependencies are isolated from your other Python projects.
1313

14+
If you havent installed pyenv, you can do it with brew:
15+
16+
```bash
17+
brew update
18+
brew install pyenv
19+
```
20+
1421
If you haven't installed pipx, you can do it with pip:
1522

1623
```bash
24+
cd airbyte-ci/connectors/ci_credentials/
25+
pyenv install # ensure you have the correct python version
1726
python -m pip install --user pipx
1827
python -m pipx ensurepath
1928
```
2029

21-
Once pipx is installed, navigate to the root directory of the project, then run:
30+
Once pyenv and pipx is installed then run the following:
2231

2332
```bash
24-
pipx install airbyte-ci/connectors/ci_credentials/
33+
pipx install --editable --force --version=python3.10 airbyte-ci/connectors/ci_credentials/
2534
```
2635

27-
This command installs ci_credentials and makes it globally available in your terminal.
36+
This command installs `ci_credentials` and makes it globally available in your terminal.
37+
38+
_Note: `--force` is required to ensure updates are applied on subsequent installs._
39+
_Note: `--version=python3.10` is required to ensure the correct python version is used._
40+
_Note: `--editable` is required to ensure the correct python version is used._
41+
42+
If you face any installation problem feel free to reach out the Airbyte Connectors Operations team.
43+
2844

2945
## Get GSM access
3046
Download a Service account json key that has access to Google Secrets Manager.

airbyte-ci/connectors/connector_ops/.python-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

airbyte-ci/connectors/pipelines/README.md

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,43 @@ This project requires Python 3.10 and pipx.
2222

2323
The recommended way to install `airbyte-ci` is using pipx. This ensures the tool and its dependencies are isolated from your other Python projects.
2424

25+
If you havent installed pyenv, you can do it with brew:
26+
27+
```bash
28+
brew update
29+
brew install pyenv
30+
```
31+
2532
If you haven't installed pipx, you can do it with pip:
2633

2734
```bash
35+
pyenv install # ensure you have the correct python version
2836
python -m pip install --user pipx
2937
python -m pipx ensurepath
3038
```
3139

32-
Once pipx is installed, navigate to the root directory of the project, then run:
40+
Once pyenv and pipx is installed then run the following:
3341

3442
```bash
35-
pipx install airbyte-ci/connectors/pipelines/ --force
43+
# install airbyte-ci
44+
pipx install --editable --force --version=python3.10 airbyte-ci/connectors/pipelines/
3645
```
3746

3847
This command installs `airbyte-ci` and makes it globally available in your terminal.
3948

4049
_Note: `--force` is required to ensure updates are applied on subsequent installs._
50+
_Note: `--version=python3.10` is required to ensure the correct python version is used._
51+
_Note: `--editable` is required to ensure the correct python version is used._
4152

4253
If you face any installation problem feel free to reach out the Airbyte Connectors Operations team.
4354

55+
### Updating the airbyte-ci tool
56+
To reinstall airbyte-ci:
57+
58+
```sh
59+
pipx reinstall pipelines
60+
```
61+
4462
## Installation for development
4563

4664
#### Pre-requisites
@@ -380,6 +398,7 @@ This command runs the Python tests for a airbyte-ci poetry package.
380398
## Changelog
381399
| Version | PR | Description |
382400
|---------| --------------------------------------------------------- |-----------------------------------------------------------------------------------------------------------|
401+
| 1.4.3 | [#30595](https://github.com/airbytehq/airbyte/pull/30595) | Add --version and version check |
383402
| 1.4.2 | [#30595](https://github.com/airbytehq/airbyte/pull/30595) | Remove directory name requirement |
384403
| 1.4.1 | [#30595](https://github.com/airbytehq/airbyte/pull/30595) | Load base migration guide into QA Test container for strict encrypt variants |
385404
| 1.4.0 | [#30330](https://github.com/airbytehq/airbyte/pull/30330) | Add support for pyproject.toml as the prefered entry point for a connector package |
@@ -414,4 +433,56 @@ This command runs the Python tests for a airbyte-ci poetry package.
414433

415434
## More info
416435
This project is owned by the Connectors Operations team.
417-
We share project updates and remaining stories before its release to production in this [EPIC](https://github.com/airbytehq/airbyte/issues/24403).
436+
We share project updates and remaining stories before its release to production in this [EPIC](https://github.com/airbytehq/airbyte/issues/24403).
437+
438+
# Troubleshooting
439+
## `airbyte-ci` is not found
440+
If you get the following error when running `airbyte-ci`:
441+
```bash
442+
$ airbyte-ci
443+
zsh: command not found: airbyte-ci
444+
```
445+
It means that the `airbyte-ci` command is not in your PATH.
446+
447+
To fix this, you can either:
448+
* Ensure that airbyte-ci is installed with pipx. Run `pipx list` to check if airbyte-ci is installed.
449+
* Run `pipx ensurepath` to add the pipx binary directory to your PATH.
450+
* Add the pipx binary directory to your PATH manually. The pipx binary directory is usually `~/.local/bin`.
451+
452+
453+
## python3.10 not found
454+
If you get the following error when running `pipx install --editable --force --version=python3.10 airbyte-ci/connectors/pipelines/`:
455+
```bash
456+
$ pipx install --editable --force --version=python3.10 airbyte-ci/connectors/pipelines/
457+
Error: Python 3.10 not found on your system.
458+
```
459+
460+
It means that you don't have Python 3.10 installed on your system.
461+
462+
To fix this, you can either:
463+
* Install Python 3.10 with pyenv. Run `pyenv install 3.10` to install the latest Python version.
464+
* Install Python 3.10 with your system package manager. For instance, on Ubuntu you can run `sudo apt install python3.10`.
465+
* Ensure that Python 3.10 is in your PATH. Run `which python3.10` to check if Python 3.10 is installed and in your PATH.
466+
467+
## Any type of pipeline failure
468+
First you should check that the version of the CLI you are using is the latest one.
469+
You can check the version of the CLI with the `--version` option:
470+
```bash
471+
$ airbyte-ci --version
472+
airbyte-ci, version 0.1.0
473+
```
474+
475+
and compare it with the version in the pyproject.toml file:
476+
```bash
477+
$ cat airbyte-ci/connectors/pipelines/pyproject.toml | grep version
478+
```
479+
480+
If you get any type of pipeline failure, you can run the pipeline with the `--show-dagger-logs` option to get more information about the failure.
481+
```bash
482+
$ airbyte-ci --show-dagger-logs connectors --name=source-pokeapi test
483+
```
484+
485+
and when in doubt, you can reinstall the CLI with the `--force` option:
486+
```bash
487+
$ pipx reinstall pipelines --force
488+
```

airbyte-ci/connectors/pipelines/pipelines/commands/airbyte_ci.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44

55
"""This module is the CLI entrypoint to the airbyte-ci commands."""
66

7+
import importlib
8+
import os
9+
import subprocess
710
from typing import List
811

912
import click
1013
from github import PullRequest
1114
from pipelines import github, main_logger
1215
from pipelines.bases import CIContext
16+
from pipelines.consts import LOCAL_PIPELINE_PACKAGE_PATH
1317
from pipelines.utils import (
1418
get_current_epoch_time,
1519
get_current_git_branch,
@@ -26,6 +30,31 @@
2630

2731
# HELPERS
2832

33+
__installed_version__ = importlib.metadata.version("pipelines")
34+
35+
36+
def check_up_to_date() -> bool:
37+
"""Check if the installed version of pipelines is up to date."""
38+
# get the version of the latest release, which is just in the pyproject.toml file of the pipelines package
39+
# as this is an internal tool, we don't need to check for the latest version on PyPI
40+
latest_version = get_latest_version()
41+
if latest_version != __installed_version__:
42+
main_logger.warning(f"pipelines is not up to date. Installed version: {__installed_version__}. Latest version: {latest_version}")
43+
main_logger.warning("Please run `pipx reinstall pipelines` to upgrade to the latest version.")
44+
return False
45+
46+
main_logger.info(f"pipelines is up to date. Installed version: {__installed_version__}. Latest version: {latest_version}")
47+
return True
48+
49+
50+
def get_latest_version() -> str:
51+
path_to_pyproject_toml = LOCAL_PIPELINE_PACKAGE_PATH + "pyproject.toml"
52+
with open(path_to_pyproject_toml, "r") as f:
53+
for line in f.readlines():
54+
if "version" in line:
55+
return line.split("=")[1].strip().replace('"', "")
56+
raise Exception("Could not find version in pyproject.toml. Please ensure you are running from the root of the airbyte repo.")
57+
2958

3059
def get_modified_files(
3160
git_branch: str, git_revision: str, diffed_branch: str, is_local: bool, ci_context: CIContext, pull_request: PullRequest
@@ -55,6 +84,7 @@ def get_modified_files(
5584

5685

5786
@click.group(help="Airbyte CI top-level command group.")
87+
@click.version_option(__installed_version__)
5888
@click.option("--is-local/--is-ci", default=True)
5989
@click.option("--git-branch", default=get_current_git_branch, envvar="CI_GIT_BRANCH")
6090
@click.option("--git-revision", default=get_current_git_revision, envvar="CI_GIT_REVISION")
@@ -99,6 +129,7 @@ def airbyte_ci(
99129
show_dagger_logs: bool,
100130
): # noqa D103
101131
ctx.ensure_object(dict)
132+
check_up_to_date()
102133
ctx.obj["is_local"] = is_local
103134
ctx.obj["is_ci"] = not is_local
104135
ctx.obj["git_branch"] = git_branch

airbyte-ci/connectors/pipelines/pipelines/consts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
GRADLE_BUILD_CACHE_PATH = f"{GRADLE_CACHE_PATH}/build-cache-1"
3333
GRADLE_READ_ONLY_DEPENDENCY_CACHE_PATH = "/root/gradle_dependency_cache"
3434
LOCAL_REPORTS_PATH_ROOT = "airbyte-ci/connectors/pipelines/pipeline_reports/"
35+
LOCAL_PIPELINE_PACKAGE_PATH = "airbyte-ci/connectors/pipelines/"
3536
DOCS_DIRECTORY_ROOT_PATH = "docs/"
3637
GCS_PUBLIC_DOMAIN = "https://storage.cloud.google.com"
3738
DOCKER_HOST_NAME = "global-docker-host"

airbyte-ci/connectors/pipelines/pipelines/dagger_run.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"_EXPERIMENTAL_DAGGER_CLOUD_TOKEN",
2323
"p.eyJ1IjogIjFiZjEwMmRjLWYyZmQtNDVhNi1iNzM1LTgxNzI1NGFkZDU2ZiIsICJpZCI6ICJlNjk3YzZiYy0yMDhiLTRlMTktODBjZC0yNjIyNGI3ZDBjMDEifQ.hT6eMOYt3KZgNoVGNYI3_v4CC-s19z8uQsBkGrBhU3k",
2424
)
25-
ARGS_DISABLING_TUI = ["--no-tui", "publish"]
25+
ARGS_DISABLING_TUI = ["--no-tui", "publish", "--version"]
2626

2727

2828
def get_dagger_path() -> Optional[str]:
@@ -97,6 +97,7 @@ def main():
9797
command = [dagger_path, "run", "airbyte-ci-internal"] + sys.argv[1:]
9898
try:
9999
try:
100+
LOGGER.info(f"Running command: {command}")
100101
subprocess.run(command, check=True)
101102
except KeyboardInterrupt:
102103
LOGGER.info("Keyboard interrupt detected. Exiting...")

0 commit comments

Comments
 (0)