From 037bb22a738547a28c6a131ceb55669d36feb659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Ho=CC=88nicke?= Date: Thu, 4 May 2023 09:30:58 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=93=A6=20fix:=20packages=20without=20?= =?UTF-8?q?version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/pypi.py | 4 +++- src/options/generate/templates_system.py | 2 +- test/unit/test_api.py | 18 +++++++++++++----- 3 files changed, 17 insertions(+), 7 deletions(-) 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..47f9e89 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 = """\ +# version does not exist but jina and docarray should not be verified jina==1.2.3 docarray==1.2.3 -requests~=2.26.0 +# 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~=1.3.1""" requirements_txt_path = os.path.join(tmpdir, "requirements.txt") with open(requirements_txt_path, "w", encoding="utf-8") as f: f.write(requirements_content) From 8d87af091d7e3c64af3ac836bbf17b6b3d944b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Ho=CC=88nicke?= Date: Thu, 4 May 2023 09:36:25 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=A6=20fix:=20packages=20without=20?= =?UTF-8?q?version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/unit/test_api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unit/test_api.py b/test/unit/test_api.py index 47f9e89..f94782c 100644 --- a/test/unit/test_api.py +++ b/test/unit/test_api.py @@ -39,8 +39,8 @@ def test_filter_packages_list(): def test_precheck_requirements_txt(tmpdir): requirements_content = """\ # version does not exist but jina and docarray should not be verified -jina==1.2.3 -docarray==1.2.3 +jina==111.222.333 +docarray==111.222.333 # package that actually exists in that version gtts~=2.2.3 # package with non-existing version @@ -58,7 +58,7 @@ docarray==111.222.333 gtts~=2.2.3 pydub~=0.25.1 requests~=2.26.0 -streamlit~=1.3.1""" +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)