or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

cli-commands.mdconfiguration.mdcore-api.mddriver-system.mdexceptions.mdindex.mdverifier-system.md

core-api.mddocs/

0

# Core API

1

2

The Molecule core API provides access to the plugin system and runtime configuration, enabling developers to extend Molecule with custom drivers and verifiers while providing programmatic access to available plugins.

3

4

## Capabilities

5

6

### Plugin Discovery Functions

7

8

Functions for discovering and accessing available drivers and verifiers in the Molecule plugin ecosystem.

9

10

```python { .api }

11

def drivers(config=None):

12

"""

13

Return list of active drivers.

14

15

Args:

16

config (Config|None): plugin config

17

18

Returns:

19

dict[str, Driver]: A dictionary of active drivers by name

20

"""

21

22

def verifiers(config=None):

23

"""

24

Return list of active verifiers.

25

26

Args:

27

config (Config|None): plugin config

28

29

Returns:

30

dict[str, Verifier]: A dictionary of active verifiers by name

31

"""

32

```

33

34

### Version Information

35

36

Access to package version information for compatibility checking and reporting.

37

38

```python { .api }

39

__version__: str # Package version string

40

version: str # Version information (alias for __version__)

41

```

42

43

### Runtime Warnings

44

45

Warning classes for handling runtime issues and compatibility problems.

46

47

```python { .api }

48

class MoleculeRuntimeWarning(RuntimeWarning):

49

"""A runtime warning used by Molecule and its plugins."""

50

51

class IncompatibleMoleculeRuntimeWarning(MoleculeRuntimeWarning):

52

"""A warning noting an unsupported runtime environment."""

53

```

54

55

## Usage Examples

56

57

### Discovering Available Plugins

58

59

```python

60

from molecule.api import drivers, verifiers

61

62

# Get all available drivers

63

available_drivers = drivers()

64

for name, driver in available_drivers.items():

65

print(f"Driver: {name}")

66

print(f" Version: {driver.version}")

67

print(f" Module: {driver.module}")

68

if driver.required_collections:

69

print(f" Required collections: {driver.required_collections}")

70

71

# Get all available verifiers

72

available_verifiers = verifiers()

73

for name, verifier in available_verifiers.items():

74

print(f"Verifier: {name}")

75

print(f" Enabled: {verifier.enabled}")

76

```

77

78

### Version Checking

79

80

```python

81

import molecule

82

83

# Check version compatibility

84

current_version = molecule.__version__

85

print(f"Running Molecule version: {current_version}")

86

87

# Version is also available as 'version'

88

assert molecule.version == molecule.__version__

89

```

90

91

### Plugin Configuration

92

93

```python

94

from molecule.config import Config

95

from molecule.api import drivers, verifiers

96

97

# Create a config instance

98

config = Config()

99

100

# Get plugins with configuration

101

configured_drivers = drivers(config)

102

configured_verifiers = verifiers(config)

103

```

104

105

## Integration Notes

106

107

- The `drivers()` and `verifiers()` functions use setuptools entry points to discover plugins

108

- Plugin loading failures are logged but don't make the entire tool unusable

109

- The functions return OrderedDict instances for consistent plugin ordering

110

- Plugin discovery is cached for performance using the `@cache` decorator