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

Trouble with importing custom packages from pylint.interfaces for local CI test #6353

Closed
shef4 opened this issue Nov 20, 2023 · 7 comments
Closed
Labels
kind/health For CI/testing/release process/refactoring/technical debt items triage/discuss Needs decision / discussion, bring these up during Cirq Cynque

Comments

@shef4
Copy link
Contributor

shef4 commented Nov 20, 2023

Description of the issue
I'm having issues trying to run some of the slow checks. I think it is because I am missing IRawChecker. Is there a way i can install this custom package or a work around?

Cirq version
1.3.0.dev

Result from running:
./check/pytest

============================= test session starts ==============================
platform linux -- Python 3.11.5, pytest-7.4.2, pluggy-1.3.0
rootdir: [/config/workspace/opensource-projects/Cirq](https://vscode-remote+code-002eatompak-002edev.vscode-resource.vscode-cdn.net/config/workspace/opensource-projects/Cirq)
configfile: pyproject.toml
plugins: anyio-4.0.0, cov-4.1.0, xdist-3.3.1
4 workers [21438 items]r                                                   
collecting 0 items [/](https://vscode-remote+code-002eatompak-002edev.vscode-resource.vscode-cdn.net/) 2 errors                                                  
==================================== ERRORS ====================================
_________ ERROR collecting dev_tools/pylint_copyright_checker_test.py __________
ImportError while importing test module '/config/workspace/opensource-projects/Cirq/dev_tools/pylint_copyright_checker_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
[/config/anaconda3/envs/cirq-py3/lib/python3.11/importlib/__init__.py](https://vscode-remote+code-002eatompak-002edev.vscode-resource.vscode-cdn.net/config/anaconda3/envs/cirq-py3/lib/python3.11/importlib/__init__.py):126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
dev_tools/pylint_copyright_checker_test.py:19: in <module>
    from dev_tools.pylint_copyright_checker import CopyrightChecker
dev_tools/pylint_copyright_checker.py:18: in <module>
    from pylint.interfaces import IRawChecker
E   ImportError: cannot import name 'IRawChecker' from 'pylint.interfaces' (/config/anaconda3/envs/cirq-py3/lib/python3.11/site-packages/pylint/interfaces.py)
_____________________________ ERROR collecting gw1 _____________________________
@shef4 shef4 added the kind/health For CI/testing/release process/refactoring/technical debt items label Nov 20, 2023
@shef4 shef4 changed the title Trouble with importing 'IRawChecker' from 'pylint.interfaces' for local CI test Trouble with importing IRawChecker from pylint.interfaces for local CI test Nov 20, 2023
@shef4 shef4 changed the title Trouble with importing IRawChecker from pylint.interfaces for local CI test Trouble with importing custom packages from pylint.interfaces for local CI test Nov 27, 2023
@dstrain115 dstrain115 added the triage/discuss Needs decision / discussion, bring these up during Cirq Cynque label Jan 2, 2024
@pavoljuhas
Copy link
Collaborator

@shef4 - please make sure you setup your development environment according to https://github.com/quantumlib/Cirq/blob/main/docs/dev/development.md#setting-up-an-environment

if there is still a problem, please post a step-by-step instructions including your Python environment setup.

@pavoljuhas
Copy link
Collaborator

Also, per @NoureldinYosri comment this may be a problem with pylint installation or having a different version installed.
Can you check if the following works?

$ python3 -c "from pylint.interfaces import IRawChecker"

@pavoljuhas
Copy link
Collaborator

likely related to #6351

@shef4
Copy link
Contributor Author

shef4 commented Jan 3, 2024

@pavoljuhas I'm not sure if this should be in a different area but wanted to share it for newer contributors. If you have any recommendation please lmk else thanks for the help!

After installing all necessary dependencies, the rest of the development cycle steps can be completed in a Jupiter notebook. This helps streamline your work as such:

  1. Open files that need to be changed and Python notebook to test changed file behavior.
  2. Install the editable version of Cirq
  3. Import circ
  4. Reproduce the issue and see if you get the same failure before and after the file change
  5. run continuous testing and verify the change
  6. *after testing you can also make a draft PR straight from VScode
Screenshot 2024-01-03 at 2 04 47 PM

@NoureldinYosri
Copy link
Collaborator

@shef4 this looks like a nice addition to your personal blog if you have one. If you don't have one maybe you should :D

@shef4
Copy link
Contributor Author

shef4 commented Jan 3, 2024

@NoureldinYosri Thanks, means a lot! I don't have one but that sounds like the perfect place for info like this.

@pavoljuhas
Copy link
Collaborator

@shef4 - one thing to keep in mind when working with Jupyter notebooks is that code changes are not reflected in the live sessions for any code that was already imported. In such case, you'd need to restart the kernel and re-run notebook cells as needed. It is also preferable to separate one-time setup (ie, installation in editable mode, installation of all package dependencies) from a test code that would be executed over and over again.

Circling back to the original subject - do you still get the ImportError for IRawChecker after following development.md to setup your environment?

If so, please reopen this issue with more detail on how to reproduce the error. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/health For CI/testing/release process/refactoring/technical debt items triage/discuss Needs decision / discussion, bring these up during Cirq Cynque
Projects
None yet
Development

No branches or pull requests

4 participants