6.4.4 Get Information About Datastores

The oml.ds.dir function provides information about datastores.

The syntax of oml.ds.dir is the following:

oml.ds.dir(name=None, regex_match=False, dstype=’user’)

Use the name parameter to get information about a specific datastore.

Optionally, you can use the regex_match and dstype parameters to get information about datastores with certain characteristics. The valid arguments for dstype are the following:

Argument Description
all

Lists all of the datastores to which the current user has the read privilege.

grant

Lists the datastores for which the current user has granted read privilege to other users.

granted

Lists the datastores for which other users have granted read privilege to the current user.

grantable

Lists the datastores that the current user can grant the read privilege to.

user

Lists the datastores created by current user.

private

Lists the datastores that the current user cannot grant the read privileges to.

The oml.ds.dir function returns a pandas.DataFrame object that contains different columns depending on which dstype argument you use. The following table lists the arguments and the columns returned for the values supplied.

dstype Argument Columns in the DataFrame Returned

user

private

grantable

DSNAME, which contains the datastore name

NOBJ, which contains the number of objects in the datastore

DSIZE, which contains the size in bytes of each object in the datastore

CDATE, which contains the creation date of the datastore

DESCRIPTION, which contains the optional description of the datastore

all

granted

All of the columns returned by the user, private, and grantable values, plus this additional column:

DSOWNER, which contains the owner of the datastore

grant

DSNAME, which contains the datastore name

GRANTEE, which contains the name of the user to which the read privilege to the datastore has been granted by the current session user

Example 6-16 Getting Information About Datastores

This example demonstrates using different combinations of arguments to the oml.ds.dir function. It demonstrates using oml.dir to list some or all of the datastores. For the creation of the datastores used in this example, see Example 6-14.

import oml

# Show all saved datastores.
oml.ds.dir(dstype="all")[['owner', 'datastore_name', 'object_count']]

# Show datastores to which other users have been granted the read 
# privilege.
oml.ds.dir(dstype="grant")

# Show datastores whose names match a pattern.
oml.ds.dir(name='pydata', regex_match=True)\
          [['datastore_name', 'object_count']]

Listing for This Example

>>> import oml
>>>
>>> # Show all saved datastores.
... oml.ds.dir(dstype="all")[['owner', 'datastore_name', 'object_count']]
     owner  datastore_name  object_count
0  OML_USER      ds_pydata             3
1  OML_USER     ds_pymodel             2
2  OML_USER   ds_wine_data             1
>>>
>>> # Show datastores to which other users have been granted the read 
>>> # privilege.
... oml.ds.dir(dstype="grant")
  datastore_name grantee
0     ds_pymodel  PUBLIC
>>>
>>> oml.ds.dir(name='pydata', regex_match=True)\
...           [['datastore_name', 'object_count']]
  datastore_name  object_count
0      ds_pydata             3