Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Fukuhara
Product and Topic Expert
Product and Topic Expert
261
Leonardo MLF plug-in SAP CP Cloud Platformの使い方を紹介します。

インストール方法はチュートリアル「Install the Machine Learning foundation plugin for SAP Cloud Platform CLI」を参照ください。

 ヘルプ確認


$ cf sapml help
A command-line interface for interacting with the SAP Leonardo Machine Learning foundation.

Usage:
cf sapml [command]

Available Commands:
config Display or modify configuration
fs Interact with training file system
help Help about any command
job Manage the training jobs
model Manage models in model repository
modelserver Manage model servers
resourceplan List the available resource plans.
retraining Retraining Service
version Print the client version information

Flags:
-h, --help Display Cloud Foundry help.
-i, --insecure Disable SSL certificate verification. Not recommended!
-v, --verbose Enable verbose output.

 

バージョン確認


cf cliとplug-nのバージョン確認
$ cf version
cf version 6.46.1+4934877ec.2019-08-23

$ cf sapml version
Client version: 1.1.5
Client commit: 34ecbbab137f58937ef80608428ce8bd0d28a027

 

fs: ファイル操作関連


fsはファイルシステム操作のコマンドです

fsのオプション一覧


$ cf sapml  help fs
Interact with training file system

The SAP Leonardo Machine Learning foundation provides a remote file system to which
the training, testing, and validation data can be uploaded and trained upon.

The training file system configuration needs to be fetched for the current
instance of the SAP Leonardo Machine Learning foundation. In this process, the training
file system will also be provisioned, in case it has not already. To initialize the training
file system, please execute 'cf sapml fs init'.

The training file system can be managed via the following sub-commands:
* init
* put
* get
* delete
* list
* config

The training file system is exposed through an Amazon S3 compliant API, whose endpoint
and credentials can get acquired by executing 'cf sapml fs config'. With these
credentials, any Amazon S3 compatible tool can be used to interact with the training file system.

All files and directories are stored in the 'data' bucket.

For more information about the sub-commands use cf sapml help config <sub-command>

Examples:
# Initialize training file system
cf sapml fs init

# List top level files and directories
cf sapml fs list

# Upload file.txt to sample.txt on the training file system
cf sapml fs put file.txt sample.txt

# Download sample.txt from the training file system
# to the local file file.txt
cf sapml fs get sample.txt file.txt

# Delete sample.txt from the training file system
cf sapml fs delete sample.txt

# Get training file system endpoint and access credentials
cf sapml fs config

Usage:
cf sapml fs [command]

Available Commands:
config Show configuration parameters for file system access
delete Delete files or directories
get Download files for directories
init Initialize remote file system
list List files and directories
put Upload files and directories

list: ファイル/ディレクトリ一覧出力


ファイル/ディレクトリ一覧出力。ファイルサイズや更新日時は出せない。

"r"オプションで全出力
$ cf sapml fs list jobs/
jobs/oilexplr-2019-08-22t0544z486562-e3f57b74-c49f-11e9-969b-eeee0a9a3410/
jobs/with-pip-20190905-0026ac37-cfda-45b9-9774-7bef9b6101c9/

# rオプションで全出力
$ cf sapml fs list jobs/ -r
jobs/oilexplr-2019-08-22t0544z486562-e3f57b74-c49f-11e9-969b-eeee0a9a3410/
jobs/with-pip-20190905-0026ac37-cfda-45b9-9774-7bef9b6101c9/check_env.py
jobs/with-pip-20190905-0026ac37-cfda-45b9-9774-7bef9b6101c9/requirements.txt
jobs/with-pip-20190905-0026ac37-cfda-45b9-9774-7bef9b6101c9/sapmljob.yaml


delete: ファイル/ディレクトリ削除


ファイル/ディレクトリを削除。

"f"オプションで確認なし削除。
$ cf sapml fs delete jobs/with-pip-20190905-0026ac37-cfda-45b9-9774-7bef9b6101c9/
Are you sure you want to delete "jobs/with-pip-20190905-0026ac37-cfda-45b9-9774-7bef9b6101c9/check_env.py" (y/N):y
Are you sure you want to delete "jobs/with-pip-20190905-0026ac37-cfda-45b9-9774-7bef9b6101c9/requirements.txt" (y/N):y
Are you sure you want to delete "jobs/with-pip-20190905-0026ac37-cfda-45b9-9774-7bef9b6101c9/sapmljob.yaml" (y/N):y
WARNING: All files matching "jobs/with-pip-20190905-0026ac37-cfda-45b9-9774-7bef9b6101c9/" will be deleted.
EOF

# 確認なしオプション
$ cf sapml fs delete -f jobs/with-pip-20190905-1e56ef1e-60b6-40f5-9ed8-93189675e96c/
WARNING: All files matching "jobs/with-pip-20190905-1e56ef1e-60b6-40f5-9ed8-93189675e96c/" will be deleted.

put: ディレクトリ/ファイルアップロード


ディレクトリ/ファイルのアップロード。ファイル名に非ascii文字や半角ブランクは入れないように注意しましょう。

OSによって書き方が違うので例が書かれているヘルプ内容を貼っておきます。
$ cf sapml help fs put
Upload files or directories to the training file system

NOTE: The path separator for the training file system is always /
independent of your operating system.

Examples:
# Upload tmpdir/file.txt to file.txt on the training file system
cf sapml fs put file.txt tmpdir/file.txt

# Windows
# Upload a file located in the path tmpdir/file.txt to C:\local\file.txt
cf sapml fs put tmpdir/file.txt C:\local\file.txt

# Linux/Mac
# Upload /local/file.txt to tmpdir/file.txt to on the training file system
cf sapml fs put /local/file.txt tmpdir/file.txt

# Windows
# Upload C:\local\tmpdir to tmpdir directory on the training file system
cf sapml fs put C:\local\tmpdir tmpdir/

# Linux/Mac
# Upload /local/tmpdir to the tmpdir directory on the training file system
cf sapml fs put /local/tmpdir/ tmpdir/

put は ファイルをアップロードするコマンドです。そのためでローカルの空ディレクトリをアップロードしようとしても無視されます(Git Pushと同じ)。Training Serviceでログやモデルファイルを置きたい空ディレクトリを作る場合はダミーファイルを置いておきましょう。また、フォルダの中身を全置換するわけではないので、クラウド側に"old.txt"というファイルがあってローカルには"new.txt"というファイルしかないディレクトリをputしてもクラウド側の"old.txt"は消えません。

ローカルの"fax"というディレクトリをルート直下にアップロードしたい場合は以下のコマンドです。2つ目の"fax/"をつけることでルートに"fax"というディレクトリを作成してくれます。
cf sapml fs put fax/ fax/

get: ファイル/ディレクトリのダウンロード


ディレクトリ/ファイルのダウンロード。

OSによって書き方が違うので例が書かれているヘルプ内容を貼っておきます。

"cat"で見られると便利なのですが、ありません。
$ cf sapml help fs get
Download files or directories from the training file system

NOTE: The path separator for the training file system is always /
independent of your operating system.

Examples:
# Download a file located in the path tmpdir/file.txt to
# file.txt in the current directory
cf sapml fs get tmpdir/file.txt file.txt

# Windows
# Download a file located in the path tmpdir/file.txt to C:\local\file.txt
cf sapml fs get tmpdir/file.txt C:\local\file.txt

# Linux/Mac
# Download a file located in the path tmpdir/file.txt to /local/file.txt
cf sapml fs get tmpdir/file.txt /local/file.txt

# Windows
# Download the tmpdir directory to C:\local\tmpdir
cf sapml fs get tmpdir/ C:\local\tmpdir

# Linux/Mac
# Download the tmpdir directory to /local/tmpdir
cf sapml fs get tmpdir/ /local/tmpdir

※ 2019/10/1 ひとまずここまでですが、今後追記していきます。