You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "potiuk (via GitHub)" <gi...@apache.org> on 2024/02/14 00:05:34 UTC
[PR] Fixed replacement of - to . in sdist package name [airflow]
potiuk opened a new pull request, #37410:
URL: https://github.com/apache/airflow/pull/37410
Follow up after #37406 - we could not test this change as there was no way to test canary builds but as the capability has been added in #37408 we can fix the failure and actually test it in a "canary" PR.
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fixed replacement of - to . in sdist package name [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #37410:
URL: https://github.com/apache/airflow/pull/37410
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fixed replacement of - to . in sdist package name [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #37410:
URL: https://github.com/apache/airflow/pull/37410#issuecomment-1942919080
> Looks like it is another part which could be simplified by [`packaging.utils`](https://packaging.pypa.io/en/stable/utils.html) ... probably one day.
A bit more complex - because we are using `provider.id` as identifier in generated provider_dependencies.json, so packaging_utils would not help :).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fixed replacement of - to . in sdist package name [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #37410:
URL: https://github.com/apache/airflow/pull/37410#issuecomment-1942952167
> > A bit more complex - because we are using provider.id as identifier in generated provider_dependencies.json
>
> I can't see a problem for generate valid canonical name from provider_id and build mapping between them (in globals?) We pretty often use provider_id and after that convert it into the package name and vice versa.
>
> ```python
> import json
> from pathlib import Path
> from packaging.utils import canonicalize_name, parse_wheel_filename, parse_sdist_filename
>
>
> PROJECT_DIR = Path("").resolve(). # Some path here
> provider_dependencies = PROJECT_DIR / "generated" / "provider_dependencies.json"
> assert provider_dependencies.exists()
>
>
> provider_dependencies_json = json.loads(provider_dependencies.read_text())
> mapping = {
> pi: canonicalize_name(f"apache-airflow-providers-{pi}") for pi in provider_dependencies_json
> }
> inverted_mapping = {v: k for k, v in mapping.items()}
> print(json.dumps(mapping, indent=2))
>
> # Samples
> sdist_files = [
> "apache-airflow-providers-airbyte-3.2.1.tar.gz",
> "apache_airflow_providers_airbyte-3.6.0.tar.gz"
> ]
>
> wheel_files = [
> "apache_airflow_providers_airbyte-3.6.0-py3-none-any.whl",
> "apache-airflow-providers-airbyte-42.0.0-py3-none-any.whl",
> # Invalid name
> "apache_airflow_providers_airbyte-42.0.0.whl",
> ]
>
> for sdist in sdist_files:
> package, _ = parse_sdist_filename(sdist)
> provider_id = inverted_mapping[package]
> print(f"Provider ID: {provider_id}, sdist: {sdist}")
>
> for wheel in wheel_files:
> package, *_ = parse_wheel_filename(wheel)
> provider_id = inverted_mapping[package]
> print(f"Provider ID: {provider_id}, sdist: {wheel}")
> ```
Ah ok yes, could be :) . Feel free :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fixed replacement of - to . in sdist package name [airflow]
Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on PR #37410:
URL: https://github.com/apache/airflow/pull/37410#issuecomment-1942944790
> A bit more complex - because we are using provider.id as identifier in generated provider_dependencies.json
I can't see a problem for generate valid canonical name from provider_id and build mapping between them (in globals?)
We pretty often use provider_id and after that convert it into the package name and vice versa.
```python
import json
from pathlib import Path
from packaging.utils import canonicalize_name, parse_wheel_filename, parse_sdist_filename
PROJECT_DIR = Path("").resolve(). # Some path here
provider_dependencies = PROJECT_DIR / "generated" / "provider_dependencies.json"
assert provider_dependencies.exists()
provider_dependencies_json = json.loads(provider_dependencies.read_text())
mapping = {
pi: canonicalize_name(f"apache-airflow-providers-{pi}") for pi in provider_dependencies_json
}
inverted_mapping = {v: k for k, v in mapping.items()}
print(json.dumps(mapping, indent=2))
# Samples
sdist_files = [
"apache-airflow-providers-airbyte-3.2.1.tar.gz",
"apache_airflow_providers_airbyte-3.6.0.tar.gz"
]
wheel_files = [
"apache_airflow_providers_airbyte-3.6.0-py3-none-any.whl",
"apache-airflow-providers-airbyte-42.0.0-py3-none-any.whl",
# Invalid name
"apache_airflow_providers_airbyte-42.0.0.whl",
]
for sdist in sdist_files:
package, _ = parse_sdist_filename(sdist)
provider_id = inverted_mapping[canonicalize_name(package)]
print(f"Provider ID: {provider_id}, sdist: {sdist}")
for wheel in wheel_files:
package, *_ = parse_wheel_filename(wheel)
provider_id = inverted_mapping[canonicalize_name(package)]
print(f"Provider ID: {provider_id}, sdist: {wheel}")
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org