Package: opendl
OpenDataLab Python SDKIMPORTANT: OpenDataLab SDK WIP, not ensure the necessary compatibility of OpenAPI and SDK. As a result, please use the SDK with thelatestversion.OpenDataLab Python SDK is a python library to accessOpendatalaband use open datasets.It provides:A pythonic way to access opendatalab resources.A convenient CLI toolodlto access open datasets.Installation$pip3installopendatalabUsage:Anaccountis needed to access to opendatalab platform.
Please visitoffical websitto get the account username and password first.HelpShow cmd help$ odl -h
$ odl --help

Usage: odl [OPTIONS] COMMAND [ARGS]...

  You can use `odl <command>` to access open datasets.

Options:
  --version   Show the version and exit.
  -h, --help  Show this message and exit.

Commands:
  get      Get(Download) dataset files into local path.
  info     Print dataset info.
  login    Login opendatalab with account.
  logout   Logout opendatalab account.
  ls       List files of the dataset.
  search   Search dataset info.
  version  Show opendatalab version.Version$ odl version
odl version, current: 0.0.2, svc: 1.8LoginLogin with opendatalab username and password. If you haven't an opendatalab account，please register with link:https://opendatalab.com/$ odl login
Username []: wangrui@pjlab.org.cn
Password []: 
Login successfully as wangrui@pjlab.org.cn
or
$ odl login -u wangrui@pjlab.org.cn
Password[]:LogoutLogout current opendatalab account$ odl logout
Do you want to logout? [y/N]: y
wangrui@pjlab.org.cn.com logoutList Dataset FilesList dataset files, support prefix of sub_directory# list all dataset files 
$ odl ls  MNIST
total: 4, size: 11.1M
+----------------------------+--------------+
| File Name                  | Size         |
+----------------------------+--------------+
| train-labels-idx1-ubyte.gz | 28.2K        |
+----------------------------+--------------+
| train-images-idx3-ubyte.gz | 9.5M         |
+----------------------------+--------------+
| t10k-labels-idx1-ubyte.gz  | 4.4K         |
+----------------------------+--------------+
| t10k-images-idx3-ubyte.gz  | 1.6M         |
+----------------------------+--------------+                                                                          	1.6M

# list sub directory files
$ odl ls MNIST/t10k
total: 2, size: 1.6M
+---------------------------+--------------+
| File Name                 | Size         |
+---------------------------+--------------+
| t10k-labels-idx1-ubyte.gz | 4.4K         |
+---------------------------+--------------+
| t10k-images-idx3-ubyte.gz | 1.6M         |
+---------------------------+--------------+# download dataset files into local  
# get all files of dataset  
$ odl get MNIST  

# get partial files of dataset  
$ odl get MNIST/t10kPython Develop Sampleimportjsonfromopendatalab.__version__import__url__fromopendatalab.cli.getimportimplement_getfromopendatalab.cli.infoimportimplement_infofromopendatalab.cli.loginimportimplement_loginfromopendatalab.cli.lsimportimplement_lsfromopendatalab.cli.searchimportimplement_searchfromopendatalab.cli.utilityimportContextInfoif__name__=='__main__':"""ContextInfo: defaultplease use shell login first, use: opendatalab login"""ctx=ContextInfo(__url__,"")client=ctx.get_client()odl_api=client.get_api()# 0. login with account# account = "xxxxx"  # your username# pw = "xxxxx"  # your password# print(f'*****'*8)# implement_login(ctx, account, pw)# 1. search demores_list=odl_api.search_dataset("coco")forindex,resinenumerate(res_list):print(f"index:{index}, result:{res['name']}")# implement_search("coco")print(f'*****'*8)# 2. list demoimplement_ls(ctx,'TAO')print(f'*****'*8)# 3. read file online demodataset=client.get_dataset('FB15k')withdataset.get('meta/info.json',False)asfd:content=json.load(fd)print(f"{content}")print(f'*****'*8)# 4. get dataset infoimplement_info(ctx,'FB15k')# 5. download# get all files of dataset# implement_get(ctx, "MNIST", 4, 0)# get partial files of datasetimplement_get(ctx,"GOT-10k/data/test_data.zip",4,0)# 139, zip 1.16G GOT-10kprint(f'*****'*5)DocumentationMore information can be found on thedocumentation site