schrodinger.utils.imputils module

Utility functions to import python modules. Always prefer loading from a location on sys.path.

Copyright Schrodinger, LLC. All rights reserved.

schrodinger.utils.imputils.import_module_from_file(filename)

Import module from a file path. Returns the imported module object.

schrodinger.utils.imputils.import_from_file(modulename, filename)
schrodinger.utils.imputils.get_path_from_module(module)

Given a module, return a path string. The path string will either be in ‘.’ format if the module can be found in either the schrodinger scripts or modules directory or an absolute path if the module is defined in a python unittest module. Inverse function of get_module_from_path.

Parameters:module – The module to export a path string for. To get the module of any arbitrary object, use inspect.getmodule.

: type module: module

schrodinger.utils.imputils.get_module_from_path(module_path)

Given a module path string generated by get_path_from_module, return the corresponding module. Inverse function of get_path_from_module.

Parameters:module_path – The path string describing the module to import

: type module_path: str