Environment
Environment
Methods:
| Name | Description |
|---|---|
import_module |
Imports the given module (if necessary) and returns a fake module object |
install |
Installs dependencies. |
launch |
Launch the environment, only available in ExternalEnvironment. Do nothing when InternalEnvironment. See |
execute_commands |
Executes the given commands in this environment. |
execute |
Execute the given function in the given module. See |
submit |
Submit a function for non-blocking execution. Returns a Task. |
submit_script |
Submit a script for non-blocking execution. Returns a Task[None]. |
map |
Execute function once for each item, distributing across workers. |
map_tasks |
Submit one task per item. Returns Task objects. |
launched |
Check if the environment is launched, important in ExternalEnvironment |
exit |
Exit the environment |
delete |
Delete this environment. Only available in ExternalEnvironment. |
update |
Update this environment with new dependencies. Only available in ExternalEnvironment. |
Source code in wetlands/environment.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
import_module(module_path)
Imports the given module (if necessary) and returns a fake module object that contains the same methods of the module which will be executed within the environment.
Source code in wetlands/environment.py
install(dependencies, additional_install_commands={})
Installs dependencies.
See EnvironmentManager.create for more details on the dependencies and additional_install_commands parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dependencies
|
Dependencies
|
Dependencies to install. |
required |
additional_install_commands
|
Commands
|
Platform-specific commands during installation. |
{}
|
Returns: Output lines of the installation commands.
Source code in wetlands/environment.py
launch(additional_activate_commands={}, max_workers=1)
Launch the environment, only available in ExternalEnvironment. Do nothing when InternalEnvironment. See ExternalEnvironment.launch
Source code in wetlands/environment.py
execute_commands(commands, additional_activate_commands={}, popen_kwargs={}, wait=False, log_context=None, log=True)
Executes the given commands in this environment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commands
|
Commands
|
The commands to execute in the environment. |
required |
additional_activate_commands
|
Commands
|
Platform-specific activation commands. |
{}
|
popen_kwargs
|
dict[str, Any]
|
Keyword arguments for subprocess.Popen(). See |
{}
|
wait
|
bool
|
Whether to wait for the process to complete before returning. |
False
|
log_context
|
dict[str, Any] | None
|
Optional context dict to attach to logs via ProcessLogger. |
None
|
log
|
bool
|
Whether to log the process output. |
True
|
Returns:
| Type | Description |
|---|---|
Popen
|
The launched process. |
Source code in wetlands/environment.py
execute(module_path, function, args=(), kwargs={})
abstractmethod
Execute the given function in the given module. See ExternalEnvironment.execute and InternalEnvironment.execute
Source code in wetlands/environment.py
submit(module_path, function, args=(), kwargs=None, *, start=True)
Submit a function for non-blocking execution. Returns a Task. Base implementation raises NotImplementedError.
Source code in wetlands/environment.py
submit_script(script_path, args=(), run_name='__main__', *, start=True)
Submit a script for non-blocking execution. Returns a Task[None].
Source code in wetlands/environment.py
map(module_path, function, iterable, *, timeout=None, ordered=True)
Execute function once for each item, distributing across workers.
Source code in wetlands/environment.py
map_tasks(module_path, function, iterable)
Submit one task per item. Returns Task objects.
Source code in wetlands/environment.py
launched()
exit()
delete()
update(dependencies=None, additional_install_commands={}, use_existing=False)
Update this environment with new dependencies. Only available in ExternalEnvironment.