Watson Studio, Watson ML, Watson OpenScale

 View Only
  • 1.  Is the Local Mode set Default Directory exposed to the Python Modeler API

    Posted Thu January 12, 2023 02:20 PM
    Edited by System Fri January 20, 2023 04:33 PM
    Hi, I found an example of how to the obtain the Server Directory:
    import modeler.api
    stream = modeler.script.stream()
    sourceNode = stream.findByID('')
    session = modeler.script.session()
    fileSystem = session.getServerFileSystem()
    parameter = stream.getParameterValue('VPATH')
    serverDirectory = fileSystem.getServerFile(parameter)
    files = fileSystem.getFiles(serverDirectory)
    for f in files:
    if f.isDirectory():
    print 'Directory:'

    But have not been able to find a sample on how to the get the Set Directory on the client side.
    Is the Local Mode set Default Directory exposed to the Python Modeler API?

    Thanks.



    ------------------------------
    Johan Peralta
    ------------------------------
    #SPSSModeler


  • 2.  RE: Is the Local Mode set Default Directory exposed to the Python Modeler API

    Posted Fri January 13, 2023 04:39 AM
    Hi,
    I cannot find the Modeler API, either.

    I change "Default Directory" before launching Modeler 

    1. session.prefs
    DefaultWorkingDirectories=C\:\\Users\\dsuser01\\Documents

    2. -directory parameter
    start "" %MODELERPATH% -directory "%DEFDIR%"

    I wrote something about this on the following article.(Sorry it is in Japanese)
    https://qiita.com/kawada2017/items/3b3ef5d5e476159163ee

    ------------------------------
    HAJIME KAWADA
    ------------------------------



  • 3.  RE: Is the Local Mode set Default Directory exposed to the Python Modeler API

    Posted Tue January 17, 2023 11:02 AM
    Edited by System Fri January 20, 2023 04:24 PM
    Hi Kadawa-san, thanks for your useful and informative response!

    The SPSS Modeler client is parsing the session.prefs file, as it knows what the set Default Directory is.
    I am wondering if the Default Directory value is available via a variable set by SPSS Modeler?



    ------------------------------
    Johan Peralta
    ------------------------------



  • 4.  RE: Is the Local Mode set Default Directory exposed to the Python Modeler API

    User Group Leader
    Posted Wed June 21, 2023 07:26 AM

    You can use the modeler.script.session().getDefaultDirectory() method to retrieve the default directory set in SPSS Modeler. Here's an example:

    import modeler.api default_directory = modeler.script.session().getDefaultDirectory() print(f"Default Directory: {default_directory}")

    This method returns the default directory as a string. It corresponds to the value set in the "Local Mode Set Default Directory" configuration in the SPSS Modeler application.



    ------------------------------
    Youssef Sbai Idrissi
    Software Engineer
    ------------------------------