How to use install_extras method in pandera

Best Python code snippet using pandera_python

noxfile.py

Source:noxfile.py Github

copy

Full Screen

1# pylint: disable=missing-module-docstring,import-error,protected-access,missing-function-docstring2import datetime3import json4import os5import pathlib6import shutil7import sys8import tempfile9from pathlib import Path10import nox11from nox.command import CommandFailed12from nox.virtualenv import VirtualEnv13# Nox options14# Reuse existing virtualenvs15nox.options.reuse_existing_virtualenvs = True16# Don't fail on missing interpreters17nox.options.error_on_missing_interpreters = False18# Python versions to test against19PYTHON_VERSIONS = ("3", "3.5", "3.6", "3.7", "3.8", "3.9")20# Be verbose when running under a CI context21CI_RUN = (22 os.environ.get("JENKINS_URL") or os.environ.get("CI") or os.environ.get("DRONE") is not None23)24PIP_INSTALL_SILENT = CI_RUN is False25SKIP_REQUIREMENTS_INSTALL = "SKIP_REQUIREMENTS_INSTALL" in os.environ26EXTRA_REQUIREMENTS_INSTALL = os.environ.get("EXTRA_REQUIREMENTS_INSTALL")27COVERAGE_VERSION_REQUIREMENT = "coverage==5.2"28SALT_REQUIREMENT = os.environ.get("SALT_REQUIREMENT") or "salt>=3003rc1"29if SALT_REQUIREMENT == "salt==master":30 SALT_REQUIREMENT = "git+https://github.com/saltstack/salt.git@master"31# Prevent Python from writing bytecode32os.environ["PYTHONDONTWRITEBYTECODE"] = "1"33# Global Path Definitions34REPO_ROOT = pathlib.Path(__file__).resolve().parent35# Change current directory to REPO_ROOT36os.chdir(str(REPO_ROOT))37ARTIFACTS_DIR = REPO_ROOT / "artifacts"38# Make sure the artifacts directory exists39ARTIFACTS_DIR.mkdir(parents=True, exist_ok=True)40RUNTESTS_LOGFILE = ARTIFACTS_DIR / "runtests-{}.log".format(41 datetime.datetime.now().strftime("%Y%m%d%H%M%S.%f")42)43COVERAGE_REPORT_DB = REPO_ROOT / ".coverage"44COVERAGE_REPORT_PROJECT = ARTIFACTS_DIR.relative_to(REPO_ROOT) / "coverage-project.xml"45COVERAGE_REPORT_TESTS = ARTIFACTS_DIR.relative_to(REPO_ROOT) / "coverage-tests.xml"46JUNIT_REPORT = ARTIFACTS_DIR.relative_to(REPO_ROOT) / "junit-report.xml"47def _get_session_python_version_info(session):48 try:49 version_info = session._runner._real_python_version_info50 except AttributeError:51 session_py_version = session.run_always(52 "python",53 "-c" 'import sys; sys.stdout.write("{}.{}.{}".format(*sys.version_info))',54 silent=True,55 log=False,56 )57 version_info = tuple(int(part) for part in session_py_version.split(".") if part.isdigit())58 session._runner._real_python_version_info = version_info59 return version_info60def _get_pydir(session):61 version_info = _get_session_python_version_info(session)62 if version_info < (3, 5):63 session.error("Only Python >= 3.5 is supported")64 return "py{}.{}".format(*version_info)65def _install_requirements(66 session,67 *passed_requirements,68 install_coverage_requirements=True,69 install_test_requirements=True,70 install_source=False,71 install_salt=True,72 install_extras=None,73):74 install_extras = install_extras or []75 if SKIP_REQUIREMENTS_INSTALL is False:76 # Always have the wheel package installed77 session.install("--progress-bar=off", "wheel", silent=PIP_INSTALL_SILENT)78 if install_coverage_requirements:79 session.install(80 "--progress-bar=off", COVERAGE_VERSION_REQUIREMENT, silent=PIP_INSTALL_SILENT81 )82 if install_salt:83 session.install("--progress-bar=off", SALT_REQUIREMENT, silent=PIP_INSTALL_SILENT)84 if install_test_requirements:85 install_extras.append("tests")86 if EXTRA_REQUIREMENTS_INSTALL:87 session.log(88 "Installing the following extra requirements because the "89 "EXTRA_REQUIREMENTS_INSTALL environment variable was set: "90 "EXTRA_REQUIREMENTS_INSTALL='%s'",91 EXTRA_REQUIREMENTS_INSTALL,92 )93 install_command = ["--progress-bar=off"]94 install_command += [req.strip() for req in EXTRA_REQUIREMENTS_INSTALL.split()]95 session.install(*passed_requirements, silent=PIP_INSTALL_SILENT)96 if install_source:97 pkg = "."98 if install_extras:99 pkg += f"[{','.join(install_extras)}]"100 session.install("-e", pkg, silent=PIP_INSTALL_SILENT)101 elif install_extras:102 pkg = f".[{','.join(install_extras)}]"103 session.install(pkg, silent=PIP_INSTALL_SILENT)104@nox.session(python=PYTHON_VERSIONS)105def tests(session):106 _install_requirements(session, install_source=True)107 sitecustomize_dir = session.run("salt-factories", "--coverage", silent=True, log=False)108 python_path_env_var = os.environ.get("PYTHONPATH") or None109 if python_path_env_var is None:110 python_path_env_var = sitecustomize_dir111 else:112 python_path_entries = python_path_env_var.split(os.pathsep)113 if sitecustomize_dir in python_path_entries:114 python_path_entries.remove(sitecustomize_dir)115 python_path_entries.insert(0, sitecustomize_dir)116 python_path_env_var = os.pathsep.join(python_path_entries)117 env = {118 # The updated python path so that sitecustomize is importable119 "PYTHONPATH": python_path_env_var,120 # The full path to the .coverage data file. Makes sure we always write121 # them to the same directory122 "COVERAGE_FILE": str(COVERAGE_REPORT_DB),123 # Instruct sub processes to also run under coverage124 "COVERAGE_PROCESS_START": str(REPO_ROOT / ".coveragerc"),125 }126 session.run("coverage", "erase")127 args = [128 "--rootdir",129 str(REPO_ROOT),130 f"--log-file={RUNTESTS_LOGFILE.relative_to(REPO_ROOT)}",131 "--log-file-level=debug",132 "--show-capture=no",133 f"--junitxml={JUNIT_REPORT}",134 "--showlocals",135 "-ra",136 "-s",137 ]138 if session._runner.global_config.forcecolor:139 args.append("--color=yes")140 if not session.posargs:141 args.append("tests/")142 else:143 for arg in session.posargs:144 if arg.startswith("--color") and args[0].startswith("--color"):145 args.pop(0)146 args.append(arg)147 for arg in session.posargs:148 if arg.startswith("-"):149 continue150 if arg.startswith(f"tests{os.sep}"):151 break152 try:153 pathlib.Path(arg).resolve().relative_to(REPO_ROOT / "tests")154 break155 except ValueError:156 continue157 else:158 args.append("tests/")159 try:160 session.run("coverage", "run", "-m", "pytest", *args, env=env)161 finally:162 # Always combine and generate the XML coverage report163 try:164 session.run("coverage", "combine")165 except CommandFailed:166 # Sometimes some of the coverage files are corrupt which would167 # trigger a CommandFailed exception168 pass169 # Generate report for salt code coverage170 session.run(171 "coverage",172 "xml",173 "-o",174 str(COVERAGE_REPORT_PROJECT),175 "--omit=tests/*",176 "--include=src/saltext/eight_ball/*",177 )178 # Generate report for tests code coverage179 session.run(180 "coverage",181 "xml",182 "-o",183 str(COVERAGE_REPORT_TESTS),184 "--omit=src/saltext/eight_ball/*",185 "--include=tests/*",186 )187 try:188 session.run(189 "coverage", "report", "--show-missing", "--include=src/saltext/eight_ball/*"190 )191 # If you also want to display the code coverage report on the CLI192 # for the tests, comment the call above and uncomment the line below193 # session.run(194 # "coverage", "report", "--show-missing",195 # "--include=src/saltext/eight_ball/*,tests/*"196 # )197 finally:198 # Move the coverage DB to artifacts/coverage in order for it to be archived by CI199 if COVERAGE_REPORT_DB.exists():200 shutil.move(str(COVERAGE_REPORT_DB), str(ARTIFACTS_DIR / COVERAGE_REPORT_DB.name))201class Tee:202 """203 Python class to mimic linux tee behaviour204 """205 def __init__(self, first, second):206 self._first = first207 self._second = second208 def write(self, buf):209 wrote = self._first.write(buf)210 self._first.flush()211 self._second.write(buf)212 self._second.flush()213 return wrote214 def fileno(self):215 return self._first.fileno()216def _lint(session, rcfile, flags, paths, tee_output=True):217 _install_requirements(218 session,219 install_salt=False,220 install_coverage_requirements=False,221 install_test_requirements=False,222 install_extras=["dev", "tests"],223 )224 if tee_output:225 session.run("pylint", "--version")226 pylint_report_path = os.environ.get("PYLINT_REPORT")227 cmd_args = ["pylint", f"--rcfile={rcfile}"] + list(flags) + list(paths)228 src_path = str(REPO_ROOT / "src")229 python_path_env_var = os.environ.get("PYTHONPATH") or None230 if python_path_env_var is None:231 python_path_env_var = src_path232 else:233 python_path_entries = python_path_env_var.split(os.pathsep)234 if src_path in python_path_entries:235 python_path_entries.remove(src_path)236 python_path_entries.insert(0, src_path)237 python_path_env_var = os.pathsep.join(python_path_entries)238 env = {239 # The updated python path so that the project is importable without installing it240 "PYTHONPATH": python_path_env_var,241 "PYTHONUNBUFFERED": "1",242 }243 cmd_kwargs = {"env": env}244 if tee_output:245 stdout = tempfile.TemporaryFile(mode="w+b")246 cmd_kwargs["stdout"] = Tee(stdout, sys.__stdout__)247 try:248 session.run(*cmd_args, **cmd_kwargs)249 finally:250 if tee_output:251 stdout.seek(0)252 contents = stdout.read()253 if contents:254 contents = contents.decode("utf-8")255 sys.stdout.write(contents)256 sys.stdout.flush()257 if pylint_report_path:258 # Write report259 with open(pylint_report_path, "w") as wfh:260 wfh.write(contents)261 session.log("Report file written to %r", pylint_report_path)262 stdout.close()263def _lint_pre_commit(session, rcfile, flags, paths):264 if "VIRTUAL_ENV" not in os.environ:265 session.error(266 "This should be running from within a virtualenv and "267 "'VIRTUAL_ENV' was not found as an environment variable."268 )269 if "pre-commit" not in os.environ["VIRTUAL_ENV"]:270 session.error(271 "This should be running from within a pre-commit virtualenv and "272 "'VIRTUAL_ENV'({}) does not appear to be a pre-commit virtualenv.".format(273 os.environ["VIRTUAL_ENV"]274 )275 )276 # Let's patch nox to make it run inside the pre-commit virtualenv277 session._runner.venv = VirtualEnv(278 os.environ["VIRTUAL_ENV"],279 interpreter=session._runner.func.python,280 reuse_existing=True,281 venv=True,282 )283 _lint(session, rcfile, flags, paths, tee_output=False)284@nox.session(python="3")285def lint(session):286 """287 Run PyLint against the code and the test suite. Set PYLINT_REPORT to a path to capture output.288 """289 session.notify(f"lint-code-{session.python}")290 session.notify(f"lint-tests-{session.python}")291@nox.session(python="3", name="lint-code")292def lint_code(session):293 """294 Run PyLint against the code. Set PYLINT_REPORT to a path to capture output.295 """296 flags = ["--disable=I"]297 if session.posargs:298 paths = session.posargs299 else:300 paths = ["setup.py", "noxfile.py", "src/"]301 _lint(session, ".pylintrc", flags, paths)302@nox.session(python="3", name="lint-tests")303def lint_tests(session):304 """305 Run PyLint against the test suite. Set PYLINT_REPORT to a path to capture output.306 """307 flags = [308 "--disable=I,redefined-outer-name,missing-function-docstring,no-member,missing-module-docstring"309 ]310 if session.posargs:311 paths = session.posargs312 else:313 paths = ["tests/"]314 _lint(session, ".pylintrc", flags, paths)315@nox.session(python=False, name="lint-code-pre-commit")316def lint_code_pre_commit(session):317 """318 Run PyLint against the code. Set PYLINT_REPORT to a path to capture output.319 """320 flags = ["--disable=I"]321 if session.posargs:322 paths = session.posargs323 else:324 paths = ["setup.py", "noxfile.py", "src/"]325 _lint_pre_commit(session, ".pylintrc", flags, paths)326@nox.session(python=False, name="lint-tests-pre-commit")327def lint_tests_pre_commit(session):328 """329 Run PyLint against the code and the test suite. Set PYLINT_REPORT to a path to capture output.330 """331 flags = [332 "--disable=I,redefined-outer-name,missing-function-docstring,no-member,missing-module-docstring",333 ]334 if session.posargs:335 paths = session.posargs336 else:337 paths = ["tests/"]338 _lint_pre_commit(session, ".pylintrc", flags, paths)339@nox.session(python="3")340def docs(session):341 """342 Build Docs343 """344 _install_requirements(345 session,346 install_coverage_requirements=False,347 install_test_requirements=False,348 install_source=True,349 install_extras=["docs"],350 )351 os.chdir("docs/")352 session.run("make", "clean", external=True)353 session.run("make", "linkcheck", "SPHINXOPTS=-W", external=True)354 session.run("make", "coverage", "SPHINXOPTS=-W", external=True)355 docs_coverage_file = os.path.join("_build", "html", "python.txt")356 if os.path.exists(docs_coverage_file):357 with open(docs_coverage_file) as rfh:358 contents = rfh.readlines()[2:]359 if contents:360 session.error("\n" + "".join(contents))361 session.run("make", "html", "SPHINXOPTS=-W", external=True)362 os.chdir(str(REPO_ROOT))363@nox.session(name="docs-html", python="3")364@nox.parametrize("clean", [False, True])365@nox.parametrize("include_api_docs", [False, True])366def docs_html(session, clean, include_api_docs):367 """368 Build Sphinx HTML Documentation369 TODO: Add option for `make linkcheck` and `make coverage`370 calls via Sphinx. Ran into problems with two when371 using Furo theme and latest Sphinx.372 """373 _install_requirements(374 session,375 install_coverage_requirements=False,376 install_test_requirements=False,377 install_source=True,378 install_extras=["docs"],379 )380 if include_api_docs:381 gen_api_docs(session)382 build_dir = Path("docs", "_build", "html")383 sphinxopts = "-Wn"384 if clean:385 sphinxopts += "E"386 args = [sphinxopts, "--keep-going", "docs", str(build_dir)]387 session.run("sphinx-build", *args, external=True)388@nox.session(name="docs-dev", python="3")389@nox.parametrize("clean", [False, True])390def docs_dev(session, clean) -> None:391 """392 Build and serve the Sphinx HTML documentation, with live reloading on file changes, via sphinx-autobuild.393 Note: Only use this in INTERACTIVE DEVELOPMENT MODE. This SHOULD NOT be called394 in CI/CD pipelines, as it will hang.395 """396 _install_requirements(397 session,398 install_coverage_requirements=False,399 install_test_requirements=False,400 install_source=True,401 install_extras=["docs", "docsauto"],402 )403 # Launching LIVE reloading Sphinx session404 build_dir = Path("docs", "_build", "html")405 args = ["--watch", ".", "--open-browser", "docs", str(build_dir)]406 if clean and build_dir.exists():407 shutil.rmtree(build_dir)408 session.run("sphinx-autobuild", *args)409@nox.session(name="docs-crosslink-info", python="3")410def docs_crosslink_info(session):411 """412 Report intersphinx cross links information413 """414 _install_requirements(415 session,416 install_coverage_requirements=False,417 install_test_requirements=False,418 install_source=True,419 install_extras=["docs"],420 )421 os.chdir("docs/")422 intersphinx_mapping = json.loads(423 session.run(424 "python",425 "-c",426 "import json; import conf; print(json.dumps(conf.intersphinx_mapping))",427 silent=True,428 log=False,429 )430 )431 try:432 mapping_entry = intersphinx_mapping[session.posargs[0]]433 except IndexError:434 session.error(435 "You need to pass at least one argument whose value must be one of: {}".format(436 ", ".join(list(intersphinx_mapping))437 )438 )439 except KeyError:440 session.error(441 "Only acceptable values for first argument are: {}".format(442 ", ".join(list(intersphinx_mapping))443 )444 )445 session.run(446 "python", "-m", "sphinx.ext.intersphinx", mapping_entry[0].rstrip("/") + "/objects.inv"447 )448 os.chdir(str(REPO_ROOT))449@nox.session(name="gen-api-docs", python="3")450def gen_api_docs(session):451 """452 Generate API Docs453 """454 _install_requirements(455 session,456 install_coverage_requirements=False,457 install_test_requirements=False,458 install_source=True,459 install_extras=["docs"],460 )461 shutil.rmtree("docs/ref")462 session.run(463 "sphinx-apidoc",464 "--implicit-namespaces",465 "--module-first",466 "-o",467 "docs/ref/",468 "src/saltext",469 "src/saltext/eight_ball/config/schemas",...

Full Screen

Full Screen

setup.py

Source:setup.py Github

copy

Full Screen

1# /setup.py2#3# Installation and setup script for psqtraviscontainer4#5# See /LICENCE.md for Copyright information6"""Installation and setup script for psqtraviscontainer."""7import platform8from setuptools import find_packages, setup9INSTALL_EXTRAS = []10if platform.system() != "Windows":11 INSTALL_EXTRAS.extend([12 "python-debian"13 ])14setup(name="polysquare-travis-container",15 version="0.0.47",16 description="""Polysquare Travis-CI Container Root""",17 long_description_markdown_filename="README.md",18 long_description_content_type="text/markdown",19 author="Sam Spilsbury",20 author_email="smspillaz@gmail.com",21 classifiers=["Development Status :: 3 - Alpha",22 "Intended Audience :: Developers",23 "Topic :: Software Development :: Build Tools",24 "License :: OSI Approved :: MIT License",25 "Programming Language :: Python :: 3",26 "Programming Language :: Python :: 3.3",27 "Programming Language :: Python :: 3.4"],28 url="http://github.com/polysquare/polysquare-travis-container",29 license="MIT",30 keywords="development travis",31 packages=find_packages(exclude=["test"]),32 install_requires=["clint",33 "parse-shebang>=0.0.3",34 "requests",35 "six",36 "shutilwhich",37 "tempdir"] + INSTALL_EXTRAS,38 extras_require={39 "upload": [40 "setuptools-markdown"41 ]42 },43 entry_points={44 "console_scripts": [45 "psq-travis-container-create=psqtraviscontainer.create:main",46 "psq-travis-container-exec=psqtraviscontainer.use:main",47 "psq-travis-container-get-root=psqtraviscontainer.rootdir:main"48 ]49 },50 test_suite="nose.collector",51 zip_safe=True,...

Full Screen

Full Screen

json_provider.py

Source:json_provider.py Github

copy

Full Screen

...18 msgs.append(f"Line {lineno}, column {colno}, {msg}")19 raise SyntaxError(f"Filename {filename}:\n" + "\n".join(msgs))20if __name__ == '__main__':21 from prettyprinter import pprint, install_extras22 install_extras()23 pprint(24 parse(r"""25\schema a = [a, b] 26 """)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pandera automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful