-
Notifications
You must be signed in to change notification settings - Fork 915
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[internal][tracing] Placeholder for
promptflow-tracing
(#2268)
# Description This PR targets to create a placeholder for upcoming tracing package `promptflow-tracing`. **Switch to `pyproject.toml` and `Poetry`** In `promptflow-tracing`, we plan to follow [PEP 518](https://peps.python.org/pep-0518/) to use `pyproject.toml`, and leverage [Poetry](https://python-poetry.org/) to manage dependencies and package. In short, with Poetry installed, one can easily set up environment with `poetry install` under `src/promptflow-tracing`, our CI workflows may also benefit from this (included in this pull request). **Versioning** Different from before, now we make version declared in `pyproject.toml`, and in code, use `importlib.metadata.version` to get it. # All Promptflow Contribution checklist: - [x] **The pull request does not introduce [breaking changes].** - [ ] **CHANGELOG is updated for new features, bug fixes or other significant changes.** - [x] **I have read the [contribution guidelines](../CONTRIBUTING.md).** - [ ] **Create an issue and link to the pull request to get dedicated review from promptflow team. Learn more: [suggested workflow](../CONTRIBUTING.md#suggested-workflow).** ## General Guidelines and Best Practices - [x] Title of the pull request is clear and informative. - [x] There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, [see this page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md). ### Testing Guidelines - [ ] Pull request includes test coverage for the included changes. --------- Co-authored-by: Clement Wang <[email protected]>
- Loading branch information
1 parent
c25be36
commit e7bceaa
Showing
9 changed files
with
244 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
name: promptflow-tracing-test | ||
|
||
on: | ||
schedule: | ||
- cron: "40 18 * * *" # 2:40 Beijing Time (GMT+8) every day | ||
pull_request: | ||
paths: | ||
- src/promptflow-tracing/** | ||
- .github/workflows/promptflow-tracing-test.yml | ||
workflow_dispatch: | ||
|
||
env: | ||
IS_IN_CI_PIPELINE: "true" | ||
WORKING_DIRECTORY: ${{ github.workspace }}/src/promptflow-tracing | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: snok/install-poetry@v1 | ||
- name: build | ||
run: poetry build | ||
working-directory: ${{ env.WORKING_DIRECTORY }} | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: promptflow-tracing | ||
path: ${{ env.WORKING_DIRECTORY }}/dist/promptflow_tracing-*.whl | ||
|
||
test: | ||
needs: build | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
python-version: ['3.8', '3.9', '3.10', '3.11'] | ||
fail-fast: false | ||
# snok/install-poetry need this to support Windows | ||
defaults: | ||
run: | ||
shell: bash | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: promptflow-tracing | ||
- name: install promptflow-tracing from wheel | ||
# wildcard expansion (*) does not work in Windows, so leverage python to find and install | ||
run: python -m pip install $(python -c "import glob; print(glob.glob('promptflow_tracing-*.whl')[0])") | ||
- uses: snok/install-poetry@v1 | ||
- name: install test dependency group | ||
run: poetry install --only test | ||
working-directory: ${{ env.WORKING_DIRECTORY }} | ||
- name: test | ||
run: poetry run pytest | ||
working-directory: ${{ env.WORKING_DIRECTORY }} | ||
- name: upload coverage report | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: report-${{ matrix.os }}-py${{ matrix.python-version }} | ||
path: | | ||
${{ env.WORKING_DIRECTORY }}/*.xml | ||
${{ env.WORKING_DIRECTORY }}/htmlcov/ | ||
report: | ||
needs: test | ||
runs-on: ubuntu-latest | ||
permissions: | ||
checks: write | ||
pull-requests: write | ||
contents: read | ||
issues: read | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
path: artifacts | ||
- uses: EnricoMi/publish-unit-test-result-action@v2 | ||
with: | ||
check_name: promptflow-tracing test result | ||
comment_title: promptflow-tracing test result | ||
files: "artifacts/**/test-results.xml" # align with `--junit-xml` in pyproject.toml | ||
- uses: irongut/[email protected] | ||
with: | ||
filename: "artifacts/report-ubuntu-latest-py3.9/coverage.xml" | ||
badge: true | ||
fail_below_min: true | ||
format: markdown | ||
hide_complexity: true | ||
output: both | ||
thresholds: 40 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,3 +185,6 @@ config.json | |
# chat-with-pdf's prebuilt index | ||
!.pdfs/ | ||
!.index/ | ||
|
||
# Poetry | ||
poetry.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Prompt flow tracing | ||
|
||
Prompt flow tracing. | ||
|
||
# Release History | ||
|
||
## 0.1.0b2 (Upcoming) | ||
|
||
- First preview version. | ||
|
||
## 0.1.0b1 (2024.03.08) | ||
|
||
- Stub version in PyPI. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# --------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# --------------------------------------------------------- | ||
|
||
from ._start_trace import start_trace | ||
from ._trace import trace | ||
from ._version import __version__ | ||
|
||
__all__ = ["__version__", "start_trace", "trace"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# --------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# --------------------------------------------------------- | ||
|
||
|
||
def start_trace(): | ||
# placeholder | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# --------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# --------------------------------------------------------- | ||
|
||
|
||
def trace(): | ||
# placeholder | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# --------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# --------------------------------------------------------- | ||
|
||
import importlib.metadata | ||
|
||
__version__ = importlib.metadata.version("promptflow-tracing") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
[tool.poetry] | ||
name = "promptflow-tracing" | ||
version = "0.1.0b2" | ||
description = "Prompt flow tracing" | ||
|
||
license = "MIT" | ||
|
||
authors = [ | ||
"Microsoft Corporation <[email protected]>" | ||
] | ||
|
||
repository = "https://github.com/microsoft/promptflow" | ||
homepage = "https://microsoft.github.io/promptflow/" | ||
|
||
readme = ["README.md"] | ||
keywords = ["telemetry"] | ||
|
||
classifiers = [ | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3 :: Only", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
] | ||
|
||
packages = [ | ||
{ include = "promptflow" } | ||
] | ||
|
||
[tool.poetry.urls] | ||
"Bug Reports" = "https://github.com/microsoft/promptflow/issues" | ||
|
||
[tool.poetry.dependencies] | ||
python = "<4.0,>=3.8" | ||
openai = "*" | ||
tiktoken = ">=0.4.0" | ||
opentelemetry-sdk = ">=1.22.0,<2.0.0" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
pre-commit = "*" | ||
|
||
[tool.poetry.group.test.dependencies] | ||
pytest = "*" | ||
pytest-cov = "*" | ||
pytest-xdist = "*" | ||
|
||
[build-system] | ||
requires = ["poetry-core>=1.5.0"] | ||
build-backend = "poetry.core.masonry.api" | ||
|
||
[tool.pytest.ini_options] | ||
markers = [ | ||
"unittest", | ||
] | ||
# junit - analyse and publish test results (https://github.com/EnricoMi/publish-unit-test-result-action) | ||
# durations - list the slowest test durations | ||
addopts = """ | ||
--junit-xml=test-results.xml \ | ||
--cov=promptflow \ | ||
--cov-config=pyproject.toml \ | ||
--cov-report=term \ | ||
--cov-report=html \ | ||
--cov-report=xml \ | ||
--dist loadfile \ | ||
--log-level=info \ | ||
--log-format="%(asctime)s %(levelname)s %(message)s" \ | ||
--log-date-format="[%Y-%m-%d %H:%M:%S]" \ | ||
--durations=5 \ | ||
-ra \ | ||
-vv | ||
""" | ||
testpaths = ["tests"] | ||
|
||
[tool.coverage.run] | ||
omit = [ | ||
"__init__.py", | ||
] | ||
|
||
[tool.black] | ||
line-length = 120 |
19 changes: 19 additions & 0 deletions
19
src/promptflow-tracing/tests/unittests/test_start_trace.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# --------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# --------------------------------------------------------- | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.unittest | ||
class TestStartTrace: | ||
def test_import(self): | ||
from promptflow.tracing import start_trace | ||
|
||
assert callable(start_trace) | ||
|
||
def test_adhoc_for_coverage(self): | ||
from promptflow.tracing import start_trace, trace | ||
|
||
start_trace() | ||
trace() |