-
Notifications
You must be signed in to change notification settings - Fork 3
Feature/update python project #655
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
Changes from 4 commits
a1c771e
78fc9ca
c3c2459
2b4bd17
b6dcec7
102a099
8c4117b
8a87f48
e06c4a0
32de8b6
eac4340
d83d182
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
|
|
||
| [tool.black] | ||
| line-length = 79 | ||
| target-version = ["py36"] | ||
| target-version = ["py310"] | ||
|
|
||
| [tool.isort] | ||
| atomic = true | ||
|
|
@@ -84,65 +84,70 @@ minversion = "6.0.0" | |
| addopts = "-vv -s --tb=native -n auto" | ||
| testpaths = "tests/" | ||
|
|
||
| [tool.poetry] | ||
| [project] | ||
| name = "pramen-py" | ||
| version = "1.11.1" | ||
| description = "Pramen transformations written in python" | ||
| authors = [ | ||
| "Artem Zhukov <[email protected]>", | ||
| "Valerii Khalimendik <[email protected]>", | ||
| "Jiří Filip <[email protected]>" | ||
| { name = "Artem Zhukov", email = "[email protected]" }, | ||
| { name = "Valerii Khalimendik", email = "[email protected]" }, | ||
| { name = "Jiří Filip", email = "[email protected]" } | ||
| ] | ||
| maintainers = [ | ||
| "Artem Zhukov <[email protected]>", | ||
| "Valerii Khalimendik <[email protected]>", | ||
| "Jiří Filip <[email protected]>" | ||
| { name = "Artem Zhukov", email = "[email protected]" }, | ||
| { name = "Valerii Khalimendik", email = "[email protected]" }, | ||
| { name = "Jiří Filip", email = "[email protected]" } | ||
| ] | ||
| readme = "README.md" | ||
| repository = "https://github.com/AbsaOSS/pramen" | ||
| packages = [ | ||
| { include = "pramen_py", from = "src" }, | ||
| { include = "pramen_py/py.typed", from = "src" }, | ||
| { include = "transformations" }, | ||
| ] | ||
| keywords = ["paramen", "pyspark", "transformations", "metastore"] | ||
| include = [ | ||
| ".env.example", | ||
| "tests/resources/real_config.yaml", | ||
| ] | ||
|
|
||
| [tool.poetry.plugins] | ||
| [tool.poetry.plugins."pytest11"] | ||
| "pramen_py" = "pramen_py.test_utils.plugin" | ||
| requires-python = ">=3.9,<4.0" | ||
|
|
||
| dependencies = [ | ||
| "click>=8.0.3", | ||
| "attrs>=21.4.0", | ||
| "rich>=11.1.0", | ||
| "contextvars>=2.4", | ||
| "environs>=9.5.0", | ||
| "PyYAML>=6.0", | ||
| "cattrs>=1.0.0; python_version<'3.7'", | ||
| "cattrs>=22.1.0; python_version>='3.7'", | ||
| "pyspark==3.5.7", | ||
| "loguru>=0.6.0", | ||
| "typing-extensions>=4.1.1", | ||
| "pyhocon>=0.3.59" | ||
| ] | ||
|
|
||
| [tool.poetry.scripts] | ||
| [project.optional-dependencies] | ||
| dev = [ | ||
| "pytest==6.2.5", | ||
| "pytest-asyncio==0.16", | ||
| "pytest-cov==2.12.1", | ||
| "types-PyYAML>=6.0.4", | ||
| "chispa>=0.9.2", | ||
| "pytest-sugar>=0.9.4", | ||
| "pytest-mock==3.6.1", | ||
| ] | ||
|
|
||
| [project.entry-points.pytest11] | ||
| pramen_py = "pramen_py.test_utils.plugin" | ||
|
|
||
| [project.scripts] | ||
| pramen-py = "pramen_py.app.cli:main" | ||
|
|
||
| [tool.poetry.dependencies] | ||
| python = ">=3.6.8,<4.0" | ||
| click = "^8.0.3" | ||
| attrs = "^21.4.0" | ||
| rich = "^11.1.0" | ||
| contextvars = "^2.4" | ||
| environs = "^9.5.0" | ||
| PyYAML = "^6.0" | ||
| cattrs = [ | ||
| {version="1.0.0", python = ">=3.6.8,<3.7"}, | ||
| {version="^22.1.0", python = ">=3.7,<4.0"}, | ||
| [tool.poetry] | ||
| packages = [ | ||
| { include = "pramen_py", from = "src" }, | ||
| { include = "pramen_py/py.typed", from = "src" }, | ||
| { include = "transformations" }, | ||
| ] | ||
| pyspark = "3.1.3" | ||
| loguru = "^0.6.0" | ||
| pytest = "6.2.5" | ||
| pytest-asyncio = "0.16" | ||
| pytest-cov = "2.12.1" | ||
| types-PyYAML = "^6.0.4" | ||
| chispa = "^0.9.2" | ||
| pytest-sugar = "^0.9.4" | ||
| pytest-mock = "3.6.1" | ||
| typing-extensions = "^4.1.1" | ||
| pyhocon = "^0.3.59" | ||
|
|
||
| [tool.poetry.dev-dependencies] | ||
|
|
||
| [tool.poetry.group.dev.dependencies] | ||
| neovim = "^0.3.1" | ||
| pdbpp = "^0.10.3" | ||
| isort = "^5.10.1" | ||
|
|
@@ -154,5 +159,5 @@ pytest-xdist = "^2.5.0" | |
| pyspark-stubs = "2.3.0.post2" | ||
|
|
||
| [build-system] | ||
| requires = ["poetry>=1.2.0"] | ||
| requires = ["poetry>=2.1.3"] | ||
| build-backend = "poetry.masonry.api" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,7 +121,14 @@ def wrapper( | |
| *args: object, | ||
| **kwargs: object, | ||
| ) -> OPS_RET: | ||
| loop = asyncio.get_event_loop() | ||
| try: | ||
| # Try to get the running event loop (Python 3.7+) | ||
| loop = asyncio.get_running_loop() | ||
| except RuntimeError: | ||
| # No running loop, create a new one | ||
| loop = asyncio.new_event_loop() | ||
| asyncio.set_event_loop(loop) | ||
|
|
||
| return loop.run_until_complete(f(*args, **kwargs)) | ||
|
Comment on lines
+124
to
132
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: If The recommended fix depends on the intended use case: Option 1: Prohibit calling from async contexts (simpler, matches typical sync-wrapper semantics): @wraps(f)
def wrapper(
*args: object,
**kwargs: object,
) -> OPS_RET:
- try:
- # Try to get the running event loop (Python 3.7+)
- loop = asyncio.get_running_loop()
- except RuntimeError:
- # No running loop, create a new one
- loop = asyncio.new_event_loop()
- asyncio.set_event_loop(loop)
-
+ # Ensure we're not inside a running loop
+ try:
+ asyncio.get_running_loop()
+ raise RuntimeError(
+ f"{f.__name__} cannot be called from an async context. "
+ "Call the async function directly instead."
+ )
+ except RuntimeError:
+ pass # No running loop, proceed
+
+ loop = asyncio.new_event_loop()
+ asyncio.set_event_loop(loop)
+ try:
- return loop.run_until_complete(f(*args, **kwargs))
+ return loop.run_until_complete(f(*args, **kwargs))
+ finally:
+ loop.close()Option 2: Support both sync and async contexts (more complex): @wraps(f)
def wrapper(
*args: object,
**kwargs: object,
) -> OPS_RET:
try:
- # Try to get the running event loop (Python 3.7+)
loop = asyncio.get_running_loop()
+ # Already in async context, schedule as task
+ import asyncio
+ task = asyncio.create_task(f(*args, **kwargs))
+ # This path should ideally return a coroutine, but the signature
+ # doesn't allow it. Consider redesigning if this path is needed.
+ raise RuntimeError(
+ f"{f.__name__} cannot be called from an async context. "
+ "Call the async function directly."
+ )
except RuntimeError:
# No running loop, create a new one
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
-
- return loop.run_until_complete(f(*args, **kwargs))
+ try:
+ return loop.run_until_complete(f(*args, **kwargs))
+ finally:
+ loop.close()Recommendation: Use Option 1 unless there's a specific requirement to support calls from async contexts. Also consider adding
🤖 Prompt for AI Agents |
||
|
|
||
| return wrapper | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Build failing due to poetry install --all-extras.
The pipeline reports a failure at this line with "poetry install stage detected invalid configuration". This is a blocker that prevents the build from completing.
The
--all-extrasflag requires properly configured optional dependency groups inpyproject.toml. Given the PEP 621 migration mentioned in the PR summary, there may be:[project.optional-dependencies]sectionPlease investigate the
pyproject.tomlconfiguration and resolve the invalid configuration error:🧰 Tools
🪛 GitHub Actions: python_ci
[error] 24-24: Command failed with exit code 1: make --silent install (poetry install stage detected invalid configuration)
🤖 Prompt for AI Agents