You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/12/16 14:26:56 UTC

[GitHub] [airflow] potiuk edited a comment on pull request #20338: Breeze2 build ci image

potiuk edited a comment on pull request #20338:
URL: https://github.com/apache/airflow/pull/20338#issuecomment-995866427


   As discussed today, good startm  one thing - it shoudl rather be quite different in terms of "global" variables. It's better to have a common way to build a structure, where we pass all the needed parameters (for example BuildParams: TypedDict) that will get all the parameters needed to execute the build and get a common logic to build this "BuildParams" object from the options provided.
   
   A lot of this commmon variables in Bash was that there is not an easy and straightforward way to execute a common code in Bash, and calculating global env variables once in common code seemed like the most efficient way of doing it, but this does not have to be done this way here.
   
   I think BuildParams should be constructed to pass all the parameters needed to derive the final parameters, but then all the actual values passed can be calculated on the flight by some methods that take those params.
   
   For example (that should be defined in a few files):
   This:
   
   ```
   function build_images::get_github_container_registry_image_prefix() {
       echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]'
   }
   
       local image_name
       image_name="ghcr.io/$(build_images::get_github_container_registry_image_prefix)"
   
       # Example:
       #  ghcr.io/apache/airflow/main/ci/python3.8
       export AIRFLOW_CI_IMAGE="${image_name}/${BRANCH_NAME}/ci/python${PYTHON_MAJOR_MINOR_VERSION}"
   
       # Example:
       #  ghcr.io/apache/airflow/main/ci/python3.8:latest
       #  ghcr.io/apache/airflow/main/ci/python3.8:<COMMIT_SHA>
       export 
   AIRFLOW_CI_IMAGE_WITH_TAG="${image_name}/${BRANCH_NAME}/ci/python${PYTHON_MAJOR_MINOR_VERSION}:${GITHUB_REGISTRY_PULL_IMAGE_TAG}"
   ```
   
   Could become this in Python (typing from memory so it might not compile :) :
   
   ```
   class BuildParams(TypedDict)
        pythonVersion: str
        githubRepository: str
        branchName: str
         ....
   
   def get_airflow_ci_image(buildParams: BuildParams, tag: Optional[str] = None):
        image=f'ghcr.io/{buildParams.gitubRepository.lower()}/{buildParams.branchName}/ci/python{buildParams.pythonVersion}'
        return image if not tag else image + f":{tag}"
   ```
   
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org