-
-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add poetry and fix problem from #23 #25
Merged
Dr-Irv
merged 44 commits into
pandas-dev:main
from
breno-jesus-fernandes:feature/poetry
Jun 15, 2022
Merged
Changes from 16 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
c9c3efa
Add poetry, all configs and dependences now are in pyproject.toml, pc…
cc394fb
Fix: Dependencies versions
3dabd25
Feature: Scratch files to document the project
697ade8
Feature: Improve CI/CD with poetry and removing pyright workaround
1a2c94f
Fix: Add black and isort in dependencies
7176fd0
Feature: Add a script to run all tests, just type "poetry run all_test"
13b1b19
Feature: Add something in documentations
ea7e6c4
Merge branch 'main' into feature/poetry
2de548e
Fix: Project version, Author, Python versions, Pandas version
8bcb394
Fix: Remove old test file documentation
cf96463
Fix: Remove old pyright configs
ec78fab
Fix: Documentation in README.md with links
9f44c9b
Fix: pyproject.toml python compatibility
34ec92a
Fix: Add tests with wheel
728e449
Fix: Remove pytests from tests against dist
7871b94
Fix: Remove Source code distribution on tests after install wheel
e5040a4
Fix: Using shutil to remove dir
9259b96
Fix: Improve local tests and fix CI tests
8d05d17
Fix: Add metadata to pyproject.toml when build a wheel
34c8305
Fix: Replace default "poetry.scripts" equivalent to console_scripts f…
b9677bd
Fix: Improving docs with instructions to update dependencies "poetry …
13d738d
Fix: Split Dev from Dist Dependencies
b646c9a
Refactor: Util test scripts
0e3ea0a
CI: All tests call poe to run
fbff5dc
Docs: Improving setup and test documentation
ce3a4f5
Refactor: Improving test_src (I still think it could be better)
b398255
Docs: Improving poe tests documentation
40836f2
Style: Apply black and isort to new scripts code
3cf7947
Fix: Bug when test_src code fails, test_dist continues to test
38a64d6
Fix: Error in test documentation
54a846a
Docs: Improving CLI help documentation to run tests
36fc564
Docs: Improving CLI help documentation to run tests
0f73192
CI: Runs CI only when change code or dependencies
1d73e23
Docs: Fix Mc Donald's english errors
fe21dd2
Fix: Package test
bc550a6
Fix: Package Test
d4467e0
CI: Fix package test
0f4eb0b
Fix: add project to sys path
5a17251
Refactor: Folder Hierarquie, Rollback job, refresh setup docs
5667178
Fix: Add rollback to test_dist
4c6d838
Feature: Add code style check
ba94941
Refactor: Improving rollback
3abae80
Feature: add clean cache option in local tests
0aaeadb
Fix: code style check
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
## Setup Environment | ||
|
||
- Make sure you have python >= 3.8 installed | ||
- Install poetry if you still don't have: pip install poetry | ||
- Install the project dependencies with: poetry install -vvv | ||
- Run all tests to make sure the project is ok: poetry run all_tests | ||
## Set Up Environment | ||
|
||
- Make sure you have `python >= 3.8` installed. </br></br> | ||
- Install poetry if you still don't have: </br> `pip install poetry`</br> </br> | ||
- Install the project dependencies with: </br> `poetry install -vvv` </br></br> | ||
- Update if you already have the project and someone added new dependencies: </br> `poetry update -vvv`</br></br> | ||
- Enter the virtual environment: </br> `poetry shell`</br></br> | ||
- Run all tests to make sure the project is ok: </br> `poe test_all` </br></br> | ||
- Do you want to add a new dependency? </br> `poetry add --dev foo-pkg ` </br></br> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
## Test | ||
|
||
- These tests originally came from https://github.com/VirtusLab/pandas-stubs. | ||
- Run local tests against source code. </br> `poe test_src` </br> </br> | ||
- Profiles: </br> | ||
- Default: Runs only mypy and pyright tests </br> `poe test_src --profile=default` </br> | ||
- Pytest: Runs only pytest </br> `poe test_src --profile=pytest` </br> | ||
- Full: Run all tests (mypy, pyright and pytests) </br> `poe test_src --profiel=full` </br> </br> | ||
|
||
- Run local tests against distribution: </br> `poe test_dist` </br> </br> | ||
|
||
- Run all local tests: </br> `poe test_all` </br> </br> | ||
|
||
- Forgot some command? </br>`poe --help` </br> </br> | ||
|
||
- These tests originally came from https://github.com/VirtusLab/pandas-stubs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import sys | ||
|
||
from loguru import logger | ||
|
||
config = { | ||
"handlers": [ | ||
{ | ||
"sink": sys.stderr, | ||
"format": ( | ||
"\n<level>===========================================</level>\n" | ||
"<level>{message}</level>\n" | ||
"<level>===========================================</level>\n" | ||
), | ||
} | ||
] | ||
} | ||
|
||
logger.configure(**config) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import time | ||
from dataclasses import dataclass | ||
from subprocess import CalledProcessError | ||
from typing import Callable, List | ||
|
||
from loguru import logger | ||
|
||
|
||
@dataclass | ||
class Step: | ||
name: str | ||
run: Callable[[], None] | ||
|
||
|
||
def run_job(steps: List[Step]) -> None: | ||
""" | ||
Responsible to run procedures with logs | ||
""" | ||
|
||
for step in steps: | ||
start = time.perf_counter() | ||
logger.info(f"Beginning to run: '{step.name}'") | ||
|
||
try: | ||
step.run() | ||
except CalledProcessError: | ||
logger.error(f"'{step.name}' failed!") | ||
break | ||
|
||
end = time.perf_counter() | ||
logger.success(f"End '{step.name}', runtime: {end - start:.3f} seconds.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import shutil | ||
import subprocess | ||
from pathlib import Path | ||
|
||
from scripts._job import Step, run_job | ||
|
||
|
||
def run_mypy_src(): | ||
cmd = ["mypy", "pandas-stubs", "tests"] | ||
subprocess.run(cmd, check=True) | ||
|
||
|
||
def run_pyright_src(): | ||
cmd = ["pyright"] | ||
subprocess.run(cmd, check=True) | ||
|
||
|
||
def run_pytest_src(): | ||
cmd = ["pytest"] | ||
subprocess.run(cmd, check=True) | ||
|
||
|
||
def test_src(profile): | ||
steps = [] | ||
|
||
# Possible steps | ||
mypy_step = Step(name="Run Mypy Against Source Code", run=run_mypy_src) | ||
pyright_step = Step(name="Run Pyright Against Source Code", run=run_pyright_src) | ||
pytest_step = Step(name="Run Pytest Against Source Code", run=run_pytest_src) | ||
|
||
# Defining which test is going to run according to a profile | ||
if profile in (None, "", "default"): | ||
steps.append(mypy_step) | ||
steps.append(pyright_step) | ||
elif profile == "pytest": | ||
steps.append(Step(name="Run Pytest Against Source Code", run=run_pytest_src)) | ||
elif profile == "full": | ||
steps.append(mypy_step) | ||
steps.append(pyright_step) | ||
steps.append(pytest_step) | ||
else: | ||
raise Exception("Profile not found!") | ||
|
||
run_job(steps) | ||
|
||
|
||
def build_dist(): | ||
cmd = ["poetry", "build", "-f", "wheel"] | ||
subprocess.run(cmd, check=True) | ||
|
||
|
||
def install_dist(): | ||
path = next(Path("dist/").glob("*.whl")) | ||
cmd = ["pip", "install", str(path), "--force-reinstall"] | ||
subprocess.run(cmd, check=True) | ||
|
||
|
||
def remove_src(): | ||
shutil.rmtree(r"pandas-stubs") | ||
|
||
|
||
def run_mypy_dist(): | ||
cmd = ["mypy", "tests"] | ||
subprocess.run(cmd, check=True) | ||
|
||
|
||
def run_pyright_dist(): | ||
cmd = ["pyright", "tests"] | ||
subprocess.run(cmd, check=True) | ||
|
||
|
||
def uninstall_dist(): | ||
cmd = ["pip", "uninstall", "-y", "pandas-stubs"] | ||
subprocess.run(cmd, check=True) | ||
|
||
|
||
def restore_src(): | ||
cmd = ["git", "checkout", "HEAD", "pandas-stubs"] | ||
subprocess.run(cmd, check=True) | ||
|
||
|
||
def install_poetry(): | ||
cmd = ["poetry", "update", "-vvv"] | ||
subprocess.run(cmd, check=True) | ||
|
||
|
||
def test_dist(): | ||
steps = [ | ||
Step(name="Build Dist", run=build_dist), | ||
Step(name="Install Dist", run=install_dist), | ||
Step(name="Remove Source Code", run=remove_src), | ||
Step(name="Run MyPy Against Dist", run=run_mypy_dist), | ||
Step(name="Run Pyright Against Dist", run=run_pyright_dist), | ||
Step(name="Uninstall Dist", run=uninstall_dist), | ||
Step(name="Restore Source Code", run=restore_src), | ||
Step(name="Install Poetry", run=install_poetry), | ||
] | ||
|
||
run_job(steps) | ||
|
||
|
||
def test_all(): | ||
steps = [ | ||
Step(name="Run Mypy Against Source Code", run=run_mypy_src), | ||
Step(name="Run Pyright Against Source Code", run=run_pyright_src), | ||
Step(name="Run Pytest Against Source Code", run=run_pytest_src), | ||
Step(name="Build Dist", run=build_dist), | ||
Step(name="Install Dist", run=install_dist), | ||
Step(name="Remove Source Code", run=remove_src), | ||
Step(name="Run MyPy Against Dist", run=run_mypy_dist), | ||
Step(name="Run Pyright Against Dist", run=run_pyright_dist), | ||
Step(name="Uninstall Dist", run=uninstall_dist), | ||
Step(name="Restore Source Code", run=restore_src), | ||
Step(name="Install Poetry", run=install_poetry), | ||
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. same comment as above about installing poetry |
||
] | ||
|
||
run_job(steps) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why do you need to install poetry when it is already installed?