You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DEVELOPMENT.md
+13Lines changed: 13 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -95,3 +95,16 @@ Automated releases are handled by the [release workflow][release-workflow] which
95
95
Testing, type checking, and formatting/linting is [checked in CI][ci].
96
96
97
97
[ci]: .github/workflows/ci.yml
98
+
99
+
## Style guide
100
+
101
+
### Adding integrations with external libraries
102
+
103
+
When adding integrations with external libraries, always use a lazy import. The external dependency should not be required to use the `cleanlab-codex` library. Wrap the lazy import in a `try`/`except` block to catch the `ImportError` and raise a `MissingDependencyError` with a helpful message. See [codex_tool.py](src/cleanlab_codex/codex_tool.py) file for examples one of which is shown below:
104
+
105
+
```python
106
+
try:
107
+
from cleanlab_codex.utils.smolagents import CodexTool as SmolagentsCodexTool
108
+
exceptImportErroras e:
109
+
raise MissingDependencyError("smolagents", "https://github.com/huggingface/smolagents") from e
0 commit comments