diff --git a/src/apis/pypi.py b/src/apis/pypi.py index 7c57a82..14d3251 100644 --- a/src/apis/pypi.py +++ b/src/apis/pypi.py @@ -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 diff --git a/src/options/generate/templates_system.py b/src/options/generate/templates_system.py index 1d31a5b..12bc7f7 100644 --- a/src/options/generate/templates_system.py +++ b/src/options/generate/templates_system.py @@ -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: diff --git a/test/unit/test_api.py b/test/unit/test_api.py index 8ebb124..f94782c 100644 --- a/test/unit/test_api.py +++ b/test/unit/test_api.py @@ -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)