Skip to content

Commit e167d83

Browse files
committed
Merge remote-tracking branch 'origin/main' into feature/litellm_cleanup
2 parents 58d16ec + de707ee commit e167d83

File tree

9 files changed

+1296
-1170
lines changed

9 files changed

+1296
-1170
lines changed

guardrails/cli/configure.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ def save_configuration_file(
4343
rc_file.writelines(lines)
4444
rc_file.close()
4545

46+
settings._initialize()
47+
4648

4749
def _get_default_token() -> str:
4850
"""Get the default token from the configuration file."""
@@ -106,6 +108,7 @@ def configure(
106108

107109
try:
108110
save_configuration_file(token, enable_metrics, remote_inferencing)
111+
# update setting singleton
109112
logger.info("Configuration saved.")
110113
except Exception as e:
111114
logger.error("An unexpected error occured saving configuration!")

guardrails/cli/create.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def generate_template_config(
118118
guard_instantiations = []
119119

120120
for i, guard in enumerate(template["guards"]):
121-
guard_instantiations.append(f"guard{i} = AsyncGuard.from_dict(guards[{i}])")
121+
guard_instantiations.append(f"guard{i} = Guard.from_dict(guards[{i}])")
122122
guard_instantiations = "\n".join(guard_instantiations)
123123
# Interpolate variables
124124
output_content = template_content.format(

guardrails/cli/hub/template_config.py.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json
22
import os
3-
from guardrails import AsyncGuard, Guard
3+
from guardrails import Guard
44
from guardrails.hub import {VALIDATOR_IMPORTS}
55

66
try:

guardrails/integrations/databricks/ml_flow_instrumentor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ def __init__(self, experiment_name: str):
5454
settings.disable_tracing = True
5555

5656
def instrument(self):
57-
if not mlflow.tracing.provider._is_enabled():
58-
mlflow.tracing.enable()
57+
mlflow.tracing.enable()
5958
mlflow.set_experiment(self.experiment_name)
6059

6160
wrapped_guard_execute = self._instrument_guard(Guard._execute)

poetry.lock

Lines changed: 1278 additions & 1154 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "guardrails-ai"
3-
version = "0.5.14"
3+
version = "0.5.15"
44
description = "Adding guardrails to large language models."
55
authors = ["Guardrails AI <[email protected]>"]
66
license = "Apache License 2.0"
@@ -56,10 +56,10 @@ opentelemetry-sdk = "^1.24.0"
5656
opentelemetry-exporter-otlp-proto-grpc = "^1.24.0"
5757
opentelemetry-exporter-otlp-proto-http = "^1.24.0"
5858
guardrails-hub-types = "^0.0.4"
59-
guardrails-api-client = ">=0.3.13"
59+
guardrails-api-client = "^0.3.13"
6060
diff-match-patch = "^20230430"
61-
guardrails-api = ">=0.0.1"
62-
mlflow = {version = ">=2.0.1", optional = true}
61+
guardrails-api = "^0.0.3"
62+
mlflow = {version = "^2.0.1", optional = true}
6363
uvloop = {version = "^0.20.0", optional = true}
6464
semver = "^3.0.2"
6565

server_ci/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json
22
import os
3-
from guardrails import AsyncGuard
3+
from guardrails import Guard
44

55
try:
66
file_path = os.path.join(os.getcwd(), "guard-template.json")
@@ -11,4 +11,4 @@
1111
SystemExit(1)
1212

1313
# instantiate guards
14-
guard0 = AsyncGuard.from_dict(guards[0])
14+
guard0 = Guard.from_dict(guards[0])

tests/unit_tests/cli/test_configure.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ def test_save_configuration_file(mocker):
6969
expanduser_mock = mocker.patch("guardrails.cli.configure.expanduser")
7070
expanduser_mock.return_value = "/Home"
7171

72+
rcexpanduser_mock = mocker.patch("guardrails.classes.rc.expanduser")
73+
rcexpanduser_mock.return_value = "/Home"
74+
7275
import os
7376

7477
join_spy = mocker.spy(os.path, "join")
@@ -88,7 +91,9 @@ def test_save_configuration_file(mocker):
8891
save_configuration_file("token", True)
8992

9093
assert expanduser_mock.called is True
91-
join_spy.assert_called_once_with("/Home", ".guardrailsrc")
94+
assert rcexpanduser_mock.called is True
95+
join_spy.assert_called_with("/Home", ".guardrailsrc")
96+
assert join_spy.call_count == 2
9297

9398
assert mock_open.call_count == 1
9499
writelines_spy.assert_called_once_with(

tests/unit_tests/integrations/databricks/test_ml_flow_instrumentor.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ def test__init__(self):
3737
assert settings.disable_tracing is True
3838

3939
def test_instrument(self, mocker):
40-
mock_is_enabled = mocker.patch(
41-
"guardrails.integrations.databricks.ml_flow_instrumentor.mlflow.tracing.provider._is_enabled",
42-
return_value=False,
43-
)
4440
mock_enable = mocker.patch(
4541
"guardrails.integrations.databricks.ml_flow_instrumentor.mlflow.tracing.enable"
4642
)
@@ -115,7 +111,6 @@ def test_instrument(self, mocker):
115111

116112
m.instrument()
117113

118-
mock_is_enabled.assert_called_once()
119114
mock_enable.assert_called_once()
120115
mock_set_experiment.assert_called_once_with("mock experiment")
121116

0 commit comments

Comments
 (0)