Skip to content

Commit

Permalink
add test to keep requirements in sync (#465)
Browse files Browse the repository at this point in the history
  • Loading branch information
leondz committed Feb 8, 2024
1 parent 4813ba3 commit 1202422
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ authors = [
{ name = "Tianhao Li" },
{ name = "Phyllis Poh" },
{ name = "Razvan Dinu" },
{ name = "Zander Mackie" },
]
license = { file = "LICENSE" }
description = "LLM vulnerability scanner"
Expand Down Expand Up @@ -52,7 +53,9 @@ dependencies = [
"cmd2",
"torch>=2.1.0",
"sentencepiece>=0.1.99",
"markdown"
"markdown",
"zalgolib>=0.2.2",
"ecoji>=0.1.0",
]

[project.urls]
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ avidtools==0.1.1.2
stdlibs
langchain>=0.0.300
nemollm>=0.3.0
octoai-sdk
octoai-sdk>=0.8.0
cmd2
torch>=2.1.0
sentencepiece>=0.1.99
markdown
zalgolib>=0.2.2
basest>=0.7.3
ecoji>=0.1.0
26 changes: 26 additions & 0 deletions tests/test_reqs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python3

# SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

import tomllib


def test_requirements_txt_pyproject_toml():
with open("requirements.txt", "r", encoding="utf-8") as req_file:
reqtxt_reqs = req_file.readlines()
reqtxt_reqs = list(map(str.strip, reqtxt_reqs))
reqtxt_reqs.sort()
with open("pyproject.toml", "rb") as pyproject_file:
pyproject_reqs = tomllib.load(pyproject_file)["project"]["dependencies"]
pyproject_reqs.sort()
# assert len(reqtxt_reqs) == len(pyproject_reqs) # same number of requirements
assert (
set(reqtxt_reqs) - set(pyproject_reqs) == set()
) # things in reqtxt but not in pyproject
assert (
set(pyproject_reqs) - set(reqtxt_reqs) == set()
) # things in pyproject but not in reqtxt
assert (
reqtxt_reqs == pyproject_reqs
) # final check. this one is actually enough, but let's help us debug by finding which test fails, ok?

0 comments on commit 1202422

Please sign in to comment.