13.5.7.5 Drop a User-Defined Python Function from the Repository
Use the oml.script.drop
function to remove a user-defined Python function from the script repository.
The oml.script.drop
function drops a user-defined Python function from the OML4Py script repository.
The syntax of the function is the following:
oml.script.drop(name, is_global=False, silent=False)
The name
argument is a string that specifies the name of the user-defined Python function in the script repository.
The is_global
argument is a boolean that specifies whether the user-defined Python function to drop is a global or a private user-defined Python function. The default value is False
, which indicates a private user-defined Python function.
The silent
argument is a boolean that specifies whether to display an error message when oml.script.drop
encounters an error in dropping the specified user-defined Python function. The default value is False
.
Example 13-14 Using the oml.script.drop Function
This example drops user-defined Python functions the MYLM private user-defined Python function and the GLBLM global user-defined Python function from the script repository. For the creation of the user-defined Python functions, see Example 13-11.
import oml
# List the available user-defined Python functions.
oml.script.dir(sctype="all")
# Drop the private user-defined Python function.
oml.script.drop("MYLM")
# Drop the global user-defined Python function.
oml.script.drop("GLBLM", is_global=True)
# List the available user-defined Python functions again.
oml.script.dir(sctype="all")
Listing for This Example
>>> import oml
>>>
>>> # List the available user-defined Python functions.
... oml.script.dir(sctype="all")
OWNER NAME SCRIPT
0 PYQSYS GLBLM def build_lm2(dat):\n from sklearn import lin...
1 OML_USER MYLM def build_lm1(dat):\n from sklearn import lin...
>>>
>>> # Drop the private user-defined Python function.
... oml.script.drop("MYLM")
>>>
>>> # Drop the global user-defined Python function.
... oml.script.drop("GLBLM", is_global=True)
>>>
>>> # List the available user-defined Python functions again.
... oml.script.dir(sctype="all")
Empty DataFrame
Columns: [OWNER, NAME, SCRIPT]
Index: []