BookmarkSubscribeRSS Feed

SAS Studio Flow을 일괄적으로 실행하는 방법

Started ‎04-28-2022 by
Modified ‎04-28-2022 by
Views 623

SAS Studio Flow를 일괄적으로 실행하는 방법과 관련해 다음과 같은 접근 방식과 스크립트를 소개합니다.

 

  • SAS Studio Flow 생성
  • SAS Studio Flow 예약
  • 작업 요청 스크립트 실행
  • 변경 내용 관리

 

가정

Gerry Nelson은 포스팅에서 SAS 관리 커맨드 라인 인터페이스를 최신 상태로 유지하는 방법에서 자세한 내용을 소개하고 있습니다.

 

그의 포스팅은 SAS Viya 2020.1 상위 버전에서 sas-viya로 대체된 sas-admin 실행 파일에 대해 다룹니다. Nelson이 소개하듯이 sas-adminsas-viya로 바꿔도 문제가 되지 않습니다.

 

배치 명령을 수행하려면 명령을 실행할 시스템에 SAS Viya CLI가 설치되어 있어야 합니다.

설치와 관련돤 설명은 SAS® Viya®: Using the Command-Line Interface에서 확인하실 수 있습니다.

 

최상위 명령어 sas-viya는 사용자를 초기화하고 인증하며 job 플러그인을 실행하는 데 사용됩니다.

전체 플러그인 목록은 Command-Line Interface: Plug-Ins을 참조하시기 바랍니다.

 

SAS Studio Flow로 돌아가기:

 

SAS Studio Flow 생성

플로우란 무엇을 뜻할까요? 데이터에 대한 일련의 작업을 의미합니다. 플로우은 SAS Viya 2020.1부터 SAS Studio에서 사용할 수 있습니다.

 

자세한 내용은  SAS® Studio with SAS® and SAS® Viya® Programming Documentation / SAS® Studio Flows. 통해 확인하실 있습니다.

 

동료들은 향후 몇 주 또는 몇 달 동안 플로우 및 활용 밥법에 대한 추가 콘텐츠 업로드 할 예정입니다.

 

다음 예제에서 플로우는 데이터 세트를 쿼리하고 결과 테이블을 생성하여 CASLIB에 로드합니다.

Daun_0-1651125815703.png

크게 보시려면 이미지를 클릭하시기 바랍니다. 모바일 버전: 이미지를 보시려면 페이지 하단의 풀 버전을 선택하세요.

 

SAS Studio Flow 예약

인터페이스에서 플로우를 사전 지정할 수 있습니다. 미리 예정 시간을 지정할 수 있습니다. 이 단계에서 일정은 작업 요청의 플로우을 변환합니다.

 

Daun_1-1651125855139.png

 

SAS Environment Manager > Jobs and Flows > 작업 요청 및 ID 예약에서 확인할 수 있습니다. ID는 플로우를 배치로 실행하는데 핵심입니다.

 

Daun_2-1651125869769.png

 

인터페이스에서 플로우을 실행하고 예약할 수 있더라도 앞서 언급한 스크립트와 SAS Viya CLI를 사용하여 SAS Studio 플로우를 실행하는 방법에 중점을 두고자 합니다.

 

작업 요청 실행

작업 요청에는 SAS Studio 플로우 코드를 포함하고 있습니다. Kubernetes 관리자로 터미널에 로그인하고 다음을 수행합니다.

 

SAS Viya 인증 및 프로필 생성

# get namespace and host, adapt the value below to your environment

current_namespace=gelenv

INGRESS_SUFFIX=$(hostname -f)

INGRESS_URL=https://${current_namespace}.${INGRESS_SUFFIX}

echo ${INGRESS_URL}

 

# get certificates (TLS support)
## run just once
mkdir -p ~/.certs
kubectl cp $(kubectl get pod -l app=sas-logon-app -o=jsonpath='{.items[0].metadata.name}'):security/trustedcerts.pem ~/.certs/${current_namespace}_trustedcerts.pem
## run as many times as you authenticate

export SSL_CERT_FILE=~/.certs/${current_namespace}_trustedcerts.pem

export REQUESTS_CA_BUNDLE=${SSL_CERT_FILE}

 

# go to sas-viya CLI folder

clidir=/opt/sas/viya/home/bin

cd $clidir

 

# create a profile

export SAS_CLI_PROFILE=${current_namespace}

./sas-viya --profile ${SAS_CLI_PROFILE} profile set-endpoint "${INGRESS_URL}"

./sas-viya --profile ${SAS_CLI_PROFILE} profile toggle-color off

./sas-viya --profile ${SAS_CLI_PROFILE} profile set-output fulljson

 

# Login and get a token, change the password

./sas-viya --profile ${SAS_CLI_PROFILE} auth login -user sasadm -password *****

 

출력 예시:

Daun_3-1651125927033.png

로그인하고 토큰을 얻는 훌륭한 안전한 접근 방식이 있습니다. 마지막 부분에서 다룰 예정입니다.

 

기존 작업 요청 나열

작업 이름으로 필터링하여 변수 jid에서 ID를 검색합니다.

# List the existing job requests

/opt/sas/viya/home/bin/sas-viya -output text job requests list -limit 25

 

# Read the id of the created job, filter by name

jid=$( /opt/sas/viya/home/bin/sas-viya --output json job requests list --filter 'eq(name,"CarMakeFlow.flw")' | jq -r '.items[]["id"]')

echo $jid

 Daun_4-1651126000602.png

 

작업 요청 실행

/opt/sas/viya/home/bin/sas-viya job requests execute --id $jid

SAS Studio 플로우를 실행합니다. SAS Environment Manager > Jobs and Flows > Scheduling에서 마지막 실행 업데이트 시간을 확인할 있습니다.

 

변경 내용 관리

SAS Studio 플로우에서 무언가를 변경하고 저장하면 어떻게 될까요? 작업 요청이 새 플로우 코드로 자체 업데이트될까요? 안타깝게도 아닙니다. 새 작업 요청으로 플로우을 다시 설정해야 합니다. 이름은 같지만 ID가 다른 두 개의 작업이 생성됩니다.

Daun_5-1651126053703.png

 

더 이상 해당 버전이 필요하지 않다고 생각되는 경우 이전 작업을 삭제하고 새 작업을 실행해야 합니다.

# Delete previous job using old jid

/opt/sas/viya/home/bin/sas-viya -output text job requests delete --id $jid 

 

## Relist the jobs

/opt/sas/viya/home/bin/sas-viya -output text job requests list -limit 25 

 

# Read the id of the new job, filter by name

jid=$( /opt/sas/viya/home/bin/sas-viya --output json job requests list --filter 'eq(name,"CarMakeFlow.flw")' | jq -r '.items[]["id"]')

echo $jid 

 

# Execute the job request based on the id of the job

/opt/sas/viya/home/bin/sas-viya job requests execute --id $jid

 

보안을 고려한 방법

보다 안전한 방법은 자격 증명을 인코딩하지 않는 것입니다. pyviya 도구와 함께 .authinfo 파일을 사용하시기 바랍니다. Gerry 포스팅 Introducing the GEL pyviyatools 통해 확인하실 있습니다.

# Instead of

# ./sas-viya --profile ${SAS_CLI_PROFILE} auth login -user sasadm -password ***** 

 

# Create .authinfo - replace ***** with real credentials

tee ~/.authinfo > /dev/null << EOF

default user sasadm password *****

EOF

 

chmod 600 ~/.authinfo

 

# Browse to PyViya Tools folder and use the loginviauthinfo command for authentification

cd ~/admin/pyviyatools.

/loginviauthinfo.py -f ~/.authinfo

pyviatools 설치 설명서는INSTALL.md에서 확인하실 수 있습니다.

 

결론

SAS Viya 2020.1 이상에서 SAS Studio Flows를 실행하려면 sas-viya 일괄 CLI 사용을 고려해보시기 바랍니다.

 

감사 말씀

Gerry Nelson Mary Kathryn Queen에게 감사드립니다.

 

리소스

자세한 내용은 다음 정보를 통해 확인하실 수 있습니다.

 

포스팅을 읽어 주셔서 감사합니다. 도움이 되셨다면 ‘좋아요’를 눌러주세요. 포스팅과 관련하여 의견을 제시해 주시거나 코멘트를 달아주시면 감사하겠습니다.

 

이곳에서 SAS Global Enablement and Learning에서 많은 기사를 찾아보실 있습니다.

Version history
Last update:
‎04-28-2022 02:15 AM
Updated by:
Contributors

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

Article Labels
Article Tags