Merge pull request #82 from jina-ai/fix_packages_without_version

📦 fix: packages without version
This commit is contained in:
Florian Hönicke
2023-05-04 10:34:02 +02:00
committed by GitHub
3 changed files with 19 additions and 9 deletions

View File

@@ -35,8 +35,10 @@ def get_latest_package_version(package_name):
# Get package versions not older than 2021
valid_versions = []
for v, release_info in releases.items():
if not release_info:
continue
upload_time = datetime.strptime(release_info[0]['upload_time'], '%Y-%m-%dT%H:%M:%S')
if upload_time.year <= 2021:
if upload_time.year <= 2020 or (upload_time.year == 2021 and upload_time.month <= 9): # knowledge cutoff 2021-09 (including september)
valid_versions.append(v)
v = max(valid_versions, key=version.parse) if valid_versions else None

View File

@@ -1,7 +1,7 @@
from src.options.generate.templates_user import not_allowed_docker_string, not_allowed_function_string
template_system_message_base = f'''It is the year 2021.
template_system_message_base = f'''It is September 2021.
You are a principal engineer working at Jina - an open source company.
You accurately satisfy all of the user's requirements.
To be more specific, you help the user to build a microservice with the following requirements:

View File

@@ -38,19 +38,27 @@ def test_filter_packages_list():
def test_precheck_requirements_txt(tmpdir):
requirements_content = """\
jina==1.2.3
docarray==1.2.3
requests~=2.26.0
# version does not exist but jina and docarray should not be verified
jina==111.222.333
docarray==111.222.333
# package that actually exists in that version
gtts~=2.2.3
# package with non-existing version
pydub~=123.123.123
# non-existing package with correct version
base64~=3.3.0
# existing package without version
requests
# another existing package without version
streamlit
"""
requirements_clean = """\
jina==1.2.3
docarray==1.2.3
requests~=2.26.0
jina==111.222.333
docarray==111.222.333
gtts~=2.2.3
pydub~=0.25.1"""
pydub~=0.25.1
requests~=2.26.0
streamlit~=0.89.0"""
requirements_txt_path = os.path.join(tmpdir, "requirements.txt")
with open(requirements_txt_path, "w", encoding="utf-8") as f:
f.write(requirements_content)