Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support Python 3.12 and transfer to .solutions #142

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
python-version: "3.12"
- name: set up node # we need node for for semantic release
uses: actions/setup-node@v2.1.2
with:
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:
- name: set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
python-version: "3.12"
- name: install dependencies
run: |
pip install -U .
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
python-version: "3.12"
- name: install python dependencies
run: |
python -m pip install --upgrade pip
Expand Down
14 changes: 7 additions & 7 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
pytest==6.2.4
Sphinx==5.3.0
pytest==8.3.2
Sphinx==8.0.2
sphinx-bootstrap-theme==0.8.1
sphinxcontrib-fulltoc==1.2.0
sphinxcontrib-websupport==1.2.4
twine==3.4.1
wheel==0.38.1
setuptools==65.5.1
jinja2==3.0.3
sphinxcontrib-websupport==2.0.0
twine==5.1.1
wheel==0.44.0
setuptools==75.1.0
jinja2==3.1
markupsafe==2.0.1
8 changes: 4 additions & 4 deletions pollination_dsl/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def translate_recipe(ctx, recipe_name, target_folder, queenbee, no_exit=False):
from queenbee_luigi.recipe import Recipe
except ImportError:
# try pollination endpoint
url = 'https://utilities.pollination.cloud/to-luigi-archive'
url = 'https://utilities.pollination.solutions/to-luigi-archive'
token = os.getenv('QB_POLLINATION_TOKEN')
assert token is not None, \
'Pollination token is not set. Use QB_POLLINATION_TOKEN to set it as ' \
Expand Down Expand Up @@ -116,14 +116,14 @@ def translate_recipe(ctx, recipe_name, target_folder, queenbee, no_exit=False):
@click.argument('package_name')
@click.option(
'-e', '--endpoint', help='Endpoint to push the resource.', show_default=True,
default='https://api.pollination.cloud'
default='https://api.pollination.solutions'
)
# TODO: Add better support for mapping different dependencies to different sources. For
# now it is all set to the same value which is fine for our use cases.
@click.option(
'-src', '--source', help='A link to replace the source for dependencies. This value '
'will overwrite the source value in recipe\'s dependencies files. By default it '
'will be set to https://api.pollination.cloud/registries'
'will be set to https://api.pollination.solutions/registries'
)
@click.option(
'--public/--private', help='Indicate if the recipe or plugin should be created as '
Expand Down Expand Up @@ -206,7 +206,7 @@ def push_resource(

# overwite resources in dependencies
if resource_type == 'recipe':
source = source or 'https://api.pollination.cloud/registries'
source = source or 'https://api.pollination.solutions/registries'
# update the value for source in dependencies.yaml file
dep_file = pathlib.Path(folder, 'dependencies.yaml')
data = yaml.safe_load(dep_file.read_bytes())
Expand Down
36 changes: 28 additions & 8 deletions pollination_dsl/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,36 @@ def get_requirement_version(package_name, dependency_name):
# try to get it from meta data
package_data = importlib_metadata.metadata(package_name)
req_dists: List[str] = package_data.get_all('Requires-Dist') or []
version = -1
for package in req_dists:
try:
if '(' in package:
name, version = package.split(' (')
else:
name, version = package.strip().split()
except ValueError as e:
print(
f'Failed to parse the dependency version for {dependency_name} '
f'from {package}. The version will not be set:\n{str(e)}'
)
requirements[dependency_name] = ''
else:
# Python 3.12
if 'not enough values to unpack' in str(e):
if '=' in package:
name, version = package.strip().split('=')
elif '>' in package:
name, version = package.strip().split('>')
elif '<' in package:
name, version = package.strip().split('<')
else:
print(
f'Failed to parse the dependency version for {dependency_name} '
f'from {package}. The version will not be set:\n{str(e)}'
)
requirements[dependency_name] = ''
else:
print(
f'Failed to parse the dependency version for {dependency_name} '
f'from {package}. The version will not be set:\n{str(e)}'
)
requirements[dependency_name] = ''

if version != -1:
version = \
version.replace('=', '').replace('>', '').replace('<', '') \
.replace(')', '').strip()
Expand Down Expand Up @@ -146,7 +163,10 @@ def get_docker_image_from_dependency(package, dependency, owner, alias=None):
image_name = alias if alias else dependency
try:
image_version = get_requirement_version(package, dependency)
image_id = f'{owner}/{image_name}:{image_version}'
if not image_version:
image_id = f'{owner}/{image_name}'
else:
image_id = f'{owner}/{image_name}:{image_version}'
except (FileNotFoundError, AssertionError) as error:
# this should not happen if the package is installed correctly
# but Python has so many ways to store requirements based on how the package
Expand All @@ -155,7 +175,7 @@ def get_docker_image_from_dependency(package, dependency, owner, alias=None):
f'Failed to pinpoint the version for {dependency} as a dependency for'
f' {package}. Will set the docker version to latest.\n{error}'
)
image_id = f'{owner}/{image_name}:latest'
image_id = f'{owner}/{image_name}'

return image_id

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
queenbee-pollination==0.7.5
queenbee-pollination==0.7.10
queenbee-local>=0.6.0
importlib-metadata>=6.6.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use_scm_version=True,
setup_requires=['setuptools_scm'],
author="Pollination",
author_email="info@pollination.cloud",
author_email="info@pollination.solutions",
description="A Python DSL to create Pollination recipes and plugins.",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
Loading