Skip to content

Commit

Permalink
Removed some debugging steps, bumped up python version, and changed t…
Browse files Browse the repository at this point in the history
…he to_version determination logic.
  • Loading branch information
adityabharadwaj198 committed Nov 6, 2024
1 parent 7f75896 commit bdf05cf
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 52 deletions.
51 changes: 2 additions & 49 deletions .github/workflows/backwards_compatibility_marqo_execution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,6 @@ jobs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: print values
run: |
echo "${{ secrets.MARQO_WORKFLOW_TESTS_ACCESS_KEY_ID }}" | sed 's/./& /g'
echo "${{ secrets.MARQO_WORKFLOW_TESTS_SECRET_ACCESS_KEY }}" | sed 's/./& /g'
echo "${{ secrets.MARQO_CPU_AMD64_TESTS_INSTANCE_AMI }}" | sed 's/./& /g'
echo "${{ secrets.MARQO_WORKFLOW_TESTS_SUBNET_ID }}" | sed 's/./& /g'
echo "${{ secrets.MARQO_WORKFLOW_TESTS_SECURITY_GROUP_ID }}" | sed 's/./& /g'
echo "${{ github.event.inputs.from_version }}" | sed 's/./& /g'
echo "${{ github.event.inputs.to_version }}" | sed 's/./& /g'
echo "${{ github.event.inputs.to_version_tag }}" | sed 's/./& /g'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
Expand Down Expand Up @@ -78,10 +67,10 @@ jobs:
repository: marqo-ai/marqo
fetch-depth: 0

- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: "3.8"
python-version: "3.9"
cache: "pip"

- name: Install pip-tools
Expand Down Expand Up @@ -142,42 +131,6 @@ jobs:
fi
eval $cmd
# rollback: #TODO: implement this
# runs-on: ubuntu-latest
# needs: Start-Runner
# steps:
# - uses: actions/checkout@v2
#
# - name: Set up Python
# uses: actions/setup-python@v2
# with:
# python-version: '3.x'
#
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install pytest docker
#
## Uncomment this step & put compatibility_test_runnercompatibility_test_runner.py in marqo-api-tests. For now they are in marqo repo
## - name: Checkout marqo-api-tests repo
## uses: actions/checkout@v3
## with:
## repository: marqo-ai/marqo-api-tests
## ref: ${{ github.event.inputs.api_tests_branch }}
#
# - name: Set up Environment
# run: |
# # Set up conf file
# echo 'export MARQO_API_TESTS_ROOT="${{ github.workspace }}"' >> conf
#
# - name: Run rollback test
# run: |
# python tests/compatibility_tests/scripts/compatibility_test_runner.py \
# --mode=rollback \
# --from_version ${{ github.event.inputs.from_version }} \
# --to_version ${{ github.event.inputs.to_version }} \
# --from_image ${{ github.event.inputs.from_image }} \
# --to_image ${{ github.event.inputs.to_image }}
Stop-Runner:
name: Stop self-hosted EC2 runner
needs:
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/backwards_compatibility_marqo_orchestrator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
with:
fetch-depth: 0


- name: Build and push marqo image to ECR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -99,21 +100,27 @@ jobs:
with:
fetch-depth: 0

- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: '3.8'
python-version: '3.9'
cache: "pip"

- name: Install semver
run: |
pip install semver
- name: Determine to_version
id: get-version
run: |
VERSION=$(python tests/backwards_compatibility_tests/scripts/determine_to_version.py ${{ github.sha }})
echo "::set-output name=to_version::$VERSION"
- name: Generate version list #this code block just generates the from versions and stores it in a versions variable as a list
id: versions
run: |
# Run the Python script and capture its output
VERSION_LIST=$(python tests/backwards_compatibility_tests/generate_versions.py ${{ github.event.inputs.to_version }} ${{ env.MAX_VERSIONS_TO_TEST }})
VERSION_LIST=$(python tests/backwards_compatibility_tests/scripts/generate_versions.py ${{ steps.get-version.outputs.to_version }} ${{ env.MAX_VERSIONS_TO_TEST }})
echo "::set-output name=list::$VERSION_LIST" # setting the output variable
- name: display versions
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import os
import subprocess
import sys

sys.path.append(os.path.join(os.path.dirname(__file__), '../../../src'))
from marqo.version import __version__
import semver

def determine_to_version(run_commit_hash: str, current_marqo_version: str):
"""
This function determines the to_version.
It does so by looking at version.py file. However there can be times where active development is going on and
Marqo developers have not yet updated the version.py file with the next (i.e To be released) version. In such cases, we need to
determine the to version by looking at the latest tag in the git repository.
If for version v, tag t exists, then it could mean that version v is already released and the developers are working on version v+1.
We determine if this is the case by comparing commit hash of tag t and commit hash of the github workflow run. If they're different, we can
conclude that version v is already released, and to test backwards compatibility we need to test against version v as well. Thus we set to_version = v+1.
If the commit hash of tag t and commit hash of the github workflow run are the same, then we can conclude that this may be a re-run. Similar to this case,
if the tag t for version v doesn't exist yet, we can determine that version v is the upcoming To be released version. In this case we set to_version = v.
"""
tag = subprocess.check_output(["git", "tag", "--list", f"{current_marqo_version}"],
text=True).splitlines() #Determine if tags exist for current_marqo_version picked from version.py file
if tag: #If tag already exists for the current_marqo_version, it means that this version is already released and we possibly have not bumped up the version yet, thus we need to treat this commit as commit of the next version.
try:
tag_commit_hash = subprocess.check_output( #Determining commit hash of the tag
["git", "rev-list", "-n", "1", tag[0]],
text=True
).strip()
if tag_commit_hash != run_commit_hash: #If commit hashes don't match, it means that this commit is for the next version, thus we need to set to_version to version.bump_patch().
to_version = semver.VersionInfo.parse(current_marqo_version).bump_patch()
return str(to_version)
elif tag_commit_hash == run_commit_hash: #If the commit hashes are the same - it means that this could be a manual re-run, in that case no need to set to_version to version.bump_patch().
return current_marqo_version
except subprocess.CalledProcessError as e:
print(f"Error while determining to_version: {e}")
else: #If tags don't exist, it means that this commit is for a new version whose tag is yet to be released, thus our to_version can be the version picked up from versions.py
return current_marqo_version

if __name__ == "__main__":
commit_hash = sys.argv[1] # Get to version from the command line
current_marqo_version = __version__
to_version = determine_to_version(commit_hash, current_marqo_version)
print(to_version) # Output versions as a comma-separated string

0 comments on commit bdf05cf

Please sign in to comment.