Notebook

Note:

The Username is case sensitive. Ensure you use the correct case for the username when accessing and executing the notebook.

Navigate to Notebook page to view the paragraphs. You can run, invalidate session, edit, add, export the notebook, and so on.

Figure 11-77 Notebook page


This image displays the Notebook page.

Note:

The following features on Notebook are not supported in the current release.
  • Cloning the notebook
  • Sharing the notebook
  • Versioning the notebook
  • Modifying the notebook
  • Deleting the notebook
  • Attaching credentials to the notebook
  • Entering dependency modes to the notebook

Inject Private Credential

  • A new button to inject private credentials is introduced in the Notebook tab of Pipeline Designer.
  • Two types of variables are supported: Environment Variables and Data Source Connection Variable.
  • Option to upload the .env file is provided.

In MMG, users can securely store their private credentials (such as database usernames and passwords) within their Python runtime session using Datasource Connection User variable types to connect to data sources. Additionally, support for environment variables has been provided. Both types of variables are scoped to the current Notebook session. Once the session is invalidated, these variables are lost, and the user will need to re-upload them.

The session of the variables is controlled by the property session-mode of Studio. If set as NOTEBOOK_USER --> the variables are only set for the Notebook session if NOTEBOOK --> shared across users, for example, if user A sets the credentials, User B will also be able to execute with the same. Users can upload a {{.env}} file that contains environment variables.

When uploaded, the variables are automatically assigned the environment variable type. To use the Datasource Connection User type, the user must manually update the type after upload.

To access these variables, users can:
  • Retrieve "environment variables" using the {{mmgsm.get_secret()}} function.
  • Access "database connections" using the {{mmg.workspace.get_conn()}} method.
The {{mmgsm.get_secret(key)}} function is used to retrieve the value of environment variables (but not database user credentials). Users also have the option to add, modify, or remove secrets through the Set Private Credentials UI.

Note:

To enable this feature, the 81275 patch needs to be applied.

Access Module for File/Folder Operations

The OFS MMG Access feature provides utility functions where code can be used with OFS MMG workspaces and the file system within the OFS MMG Studio to perfrom file/folder related operations.

It is assumed that the module has already been imported by using one of the following codes:

from mmg.access import

or

import mmg.access as mac

Note:

The workspace attachment step must be performed before using any of the following API mentioned in this section. The current working directory will always be the path inside the FTPSHARE of the attached workspace. For example, <FTPSHARE_PATH>/mmg/<WS>

If the source and the destination starts with /, then it is assumed to be an absolute path (as is the case with os and shutil. Hence, to maintain the compatibility, the same is the case with the OFS MMG access feature module APIs

Table 11-20 List of APIs

Name Description Usage Example Note
getcwd Returns the current working directory path within MMG FTPSHARE for the active workspace. getcwd() The getcwd() function returns the path inside the attached workspace that is within FTPSHARE. It does not reflect the actual cwd path that is returned from the os.getcwd() function. Hence, using os.chdir() will not affect the getcwd() function implemented from the OFS MMG access module library.
move Moves a file or directory to another location. move(src='/source/path', dst='/destination/path')  
copy Copies a file with metadata from one location to another. copy(src='/source/path', dst='/destination/path')  
copyfile Copies a file without its' metadata. copyfile(src='/source/file', dst='/destination/file')  
copytree Recursively copies a directory tree to the destination. copytree(src='/source/dir', dst='/destination/dir', dirs_exist_ok=True)  
listdir Lists all files in the specified directory. listdir(path='/your/dir')  
remove Removes a single file from the specified path. remove(path='/file/to/remove')  
rename Renames a file within the current workspace. rename(src='/old/filename', dst='/new/filename')