Giter VIP home page Giter VIP logo

crunchdjango's People

Watchers

 avatar  avatar

crunchdjango's Issues

Airflow 변수 사용 문제

주석에 질문 있습니다!

# 이 밑의 solutionVersionArn 변수를 여러 함수가 사용하려고 해요
solutionVersionArn = ''

# update solution version
def make_new_solution_version(**kwargs):
    personalize = boto3.client('personalize', region_name='us-east-1', aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID'), aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY'))
    response = personalize.create_solution_version(
        solutionArn = 'arn:aws:personalize:us-east-1:051972272913:solution/crunch-solutionV3'
    )
    logging.info('Response: ' + str(response))

    description = personalize.describe_solution_version(
        solutionVersionArn = response['solutionVersionArn']
    )

    status = description["solutionVersion"]["status"]
    logging.info('Progress: ' + str(description['solutionVersion']['status']))
    
    while description["solutionVersion"]["status"] != 'ACTIVE':
        time.sleep(30)
        description = personalize.describe_solution_version(
            solutionVersionArn = response['solutionVersionArn']
        )
        logging.info('Progress: ' + str(description['solutionVersion']['status']))
    
    global solutionVersionArn
    solutionVersionArn = response['solutionVersionArn']
    #################### 여기서 response로 받아온걸 solutionVersionArn로 할당해주는데요, 이 밑의 함수에서 사용하려고 하면 그냥 빈 스트링으로 나옵니다.
    logging.info('solutionVersionArn: ' + solutionVersionArn)

update_new_solution_version = PythonOperator(
            task_id='update_new_solution_version',
            python_callable=make_new_solution_version,
            provide_context=True,
            execution_timeout=timedelta(minutes=240),
            dag=dag
)


# update campaign version
def make_update_campaign_version(**kwargs):
    client= boto3.client('personalize', region_name='us-east-1', aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID'), aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY'))

    logging.info('solutionVersionArn: ' + solutionVersionArn)
    # 여기서 콘솔을 찍으면 solutionVersionArn이 빈 스트링으로 나와요. 어떻게 해야 위의 함수에서 할당받은 애를 쓸 수 있을까요? logging.info 바로 윗줄에 global solutionVersionArn 선언해주면 되나요?

    response = client.update_campaign(
        campaignArn='arn:aws:personalize:us-east-1:051972272913:campaign/crunch-campaignv2',
        solutionVersionArn=solutionVersionArn,
    )

update_campagin_version = PythonOperator(
            task_id='update_campaign_version',
            python_callable=make_update_campaign_version,
            provide_context=True,
            execution_timeout=timedelta(minutes=180),
            dag=dag
)


update_new_solution_version >> update_campagin_version

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.