Skip to content

Commit

Permalink
Include stats in readProject (#408)
Browse files Browse the repository at this point in the history
and speed up int tests
  • Loading branch information
hinthornw authored Feb 7, 2024
1 parent 8fdd2f4 commit 8e26d22
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/actions/python-integration-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ runs:
LANGCHAIN_TRACING_V2: "true"
LANGCHAIN_API_KEY: ${{ inputs.langchain-api-key }}
OPENAI_API_KEY: ${{ inputs.openai-api-key }}
run: make integration_tests
run: make integration_tests_fast
shell: bash
working-directory: python
4 changes: 2 additions & 2 deletions python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ tests_watch:
poetry run ptw --now . -- -vv -x tests/unit_tests

integration_tests:
poetry run pytest tests/integration_tests
poetry run pytest -v --durations=10 --cov=langsmith --cov-report=term-missing --cov-report=html --cov-config=.coveragerc tests/integration_tests

integration_tests_fast:
poetry run pytest -n auto tests/integration_tests
poetry run pytest -n auto --durations=10 -v --cov=langsmith --cov-report=term-missing --cov-report=html --cov-config=.coveragerc tests/integration_tests

lint:
poetry run ruff .
Expand Down
23 changes: 23 additions & 0 deletions python/langsmith/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1655,6 +1655,29 @@ def read_project(
**response.json(), _host_url=self._host_url
)

def has_project(
self, project_name: str, *, project_id: Optional[str] = None
) -> bool:
"""Check if a project exists.
Parameters
----------
project_name : str
The name of the project to check for.
project_id : str or None, default=None
The ID of the project to check for.
Returns
-------
bool
Whether the project exists.
"""
try:
self.read_project(project_name=project_name)
except ls_utils.LangSmithNotFoundError:
return False
return True

def get_test_results(
self,
*,
Expand Down
101 changes: 87 additions & 14 deletions python/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ freezegun = "^1.2.2"
pytest-subtests = "^0.11.0"
pytest-watcher = "^0.3.4"
pytest-xdist = "^3.5.0"
pytest-cov = "^4.1.0"

[tool.poetry.group.lint.dependencies]
openai = "^1.10"
Expand Down
Loading

0 comments on commit 8e26d22

Please sign in to comment.