Orchestration Pipeline 사용자 정의 컴포넌트는 사용자가 작성하는 스크립트를 실행합니다. 사용자 정의 컴포넌트를 사용하여 파이프라인 간에 재사용 가능한 스크립트를 공유할 수 있습니다.
사용자 정의 컴포넌트를 프로젝트 자산으로 작성합니다. 그런 다음 해당 프로젝트에서 작성하는 파이프라인의 컴포넌트를 사용할 수 있습니다. 필요한 만큼 파이프라인에 대한 사용자 정의 컴포넌트를 작성할 수 있습니다. 현재 Python 함수를 사용하여 프로그래밍 방식으로 사용자 정의 구성요소를 작성해야 합니다.
프로젝트 자산으로 컴포넌트 작성
사용자 정의 컴포넌트를 작성하려면 Python 클라이언트를 사용하여 IBM Orchestration 파이프라인으로 인증하고 컴포넌트를 코딩한 후 지정된 프로젝트에 컴포넌트를 공개하십시오. 프로젝트에서 사용 가능하게 되면 파이프라인의 노드에 컴포넌트를 지정하고 파이프라인 플로우의 일부로 실행할 수 있습니다.
이 예제는 두 개의 숫자를 함께 추가한 후 파이프라인 노드에 컴포넌트를 지정하는 컴포넌트를 공개하는 프로세스를 보여줍니다.
Python 클라이언트를 사용하여 구성요소로 함수를 게시하십시오. Cloud Pak for Data as a Service프로젝트의 Jupyter Notebook 에서 다음 코드를 실행하십시오.
# Install libraries ! pip install ibm-orchestration-pipelines # Authentication from ibm_orchestration_pipelines import OrchestrationPipelines apikey = '' project_id = 'your_project_id' client = OrchestrationPipelines(apikey, url=service_url) # Define the function of the component # If you define the input parameters, users are required to # input them in the UI def add_two_numbers(a: int, b: int) -> int: print('Adding numbers: {} + {}.'.format(a, b)) return a + b + 10 # Other possible functions might be sending a Slack message, # or listing directories in a storage volume, and so on. # Publish the component client.publish_component( name='Add numbers', # Appears in UI as component name func=add_two_numbers, description='Custom component adding numbers', # Appears in UI as component description project_id=project_id, overwrite=True, # Overwrites an existing component with the same name )
새 API키를 생성하려면 다음을 수행하십시오.
- IBM Cloud 홈 페이지 로 이동하십시오.
- 관리 > 액세스 (IAM) 를 클릭하십시오.
- API키 클릭
- 작성 클릭
실행 아래의 파이프라인 컴포넌트 실행 이라는 노드를 캔버스로 끌어오십시오.
사용할 구성요소의 이름을 선택하십시오.
파이프라인 작업의 일부로 노드를 연결하고 실행하십시오.
파이프라인 구성요소 관리
이러한 Python 클라이언트 메소드를 사용하여 사용자 정의 파이프라인 구성요소를 관리하십시오.
방법 | 함수 |
---|---|
client.get_components(project_id=project_id) |
프로젝트의 컴포넌트 나열 |
client.get_component(project_id=project_id, component_id=component_id) |
ID별 컴포넌트 가져오기 |
client.get_component(project_id=project_id, name=component_name) |
이름별 컴포넌트 가져오기 |
client.publish_component(component name) |
새 컴포넌트 공개 |
client.delete_component(project_id=project_id, component_id=component_id) |
ID로 컴포넌트 삭제 |
상위 주제: 파이프라인 작성