mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-08 02:24:04 +00:00
Fix python codestyle
This commit is contained in:
@@ -7,7 +7,7 @@ import os
|
||||
import errno
|
||||
import stat
|
||||
|
||||
c = get_config()
|
||||
c = get_config() # noqa: F821
|
||||
c.NotebookApp.ip = '0.0.0.0'
|
||||
c.NotebookApp.port = 8888
|
||||
c.NotebookApp.open_browser = False
|
||||
|
@@ -70,8 +70,10 @@ def test_nb_user_change(container):
|
||||
running_container = container.run(
|
||||
tty=True,
|
||||
user="root",
|
||||
environment=[f"NB_USER={nb_user}",
|
||||
"CHOWN_HOME=yes"],
|
||||
environment=[
|
||||
f"NB_USER={nb_user}",
|
||||
"CHOWN_HOME=yes"
|
||||
],
|
||||
working_dir=f"/home/{nb_user}",
|
||||
command=['start.sh', 'bash', '-c', 'sleep infinity']
|
||||
)
|
||||
@@ -100,10 +102,11 @@ def test_chown_extra(container):
|
||||
c = container.run(
|
||||
tty=True,
|
||||
user='root',
|
||||
environment=['NB_UID=1010',
|
||||
'NB_GID=101',
|
||||
'CHOWN_EXTRA=/opt/conda',
|
||||
'CHOWN_EXTRA_OPTS=-R',
|
||||
environment=[
|
||||
'NB_UID=1010',
|
||||
'NB_GID=101',
|
||||
'CHOWN_EXTRA=/opt/conda',
|
||||
'CHOWN_EXTRA_OPTS=-R'
|
||||
],
|
||||
command=['start.sh', 'bash', '-c', 'stat -c \'%n:%u:%g\' /opt/conda/LICENSE.txt']
|
||||
)
|
||||
@@ -118,8 +121,9 @@ def test_chown_home(container):
|
||||
c = container.run(
|
||||
tty=True,
|
||||
user='root',
|
||||
environment=['CHOWN_HOME=yes',
|
||||
'CHOWN_HOME_OPTS=-R',
|
||||
environment=[
|
||||
'CHOWN_HOME=yes',
|
||||
'CHOWN_HOME_OPTS=-R'
|
||||
],
|
||||
command=['start.sh', 'bash', '-c', 'chown root:root /home/jovyan && ls -alsh /home']
|
||||
)
|
||||
|
@@ -3,8 +3,6 @@
|
||||
|
||||
import logging
|
||||
|
||||
import pytest
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -17,4 +15,3 @@ def test_pandoc(container):
|
||||
logs = c.logs(stdout=True).decode("utf-8")
|
||||
LOGGER.debug(logs)
|
||||
assert "<p><strong>BOLD</strong></p>" in logs
|
||||
|
||||
|
@@ -13,6 +13,7 @@ from requests.adapters import HTTPAdapter
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def http_client():
|
||||
"""Requests session with retries and backoff."""
|
||||
|
@@ -2,18 +2,16 @@
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
import logging
|
||||
|
||||
import pytest
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def test_julia(container):
|
||||
"""Basic julia test"""
|
||||
LOGGER.info(f"Test that julia is correctly installed ...")
|
||||
LOGGER.info("Test that julia is correctly installed ...")
|
||||
running_container = container.run(
|
||||
tty=True, command=["start.sh", "bash", "-c", "sleep infinity"]
|
||||
)
|
||||
command = f"julia --version"
|
||||
command = "julia --version"
|
||||
cmd = running_container.exec_run(command)
|
||||
output = cmd.output.decode("utf-8")
|
||||
assert cmd.exit_code == 0, f"Command {command} failed {output}"
|
||||
|
5
docs/conf.py
Normal file → Executable file
5
docs/conf.py
Normal file → Executable file
@@ -21,11 +21,6 @@
|
||||
# import sys
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# For conversion from markdown to html
|
||||
import recommonmark.parser
|
||||
from recommonmark.transform import AutoStructify
|
||||
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
|
@@ -1,12 +1,11 @@
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
import time
|
||||
import logging
|
||||
|
||||
import pytest
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def test_spark_shell(container):
|
||||
"""Checking if Spark (spark-shell) is running properly"""
|
||||
c = container.run(
|
||||
@@ -18,6 +17,7 @@ def test_spark_shell(container):
|
||||
LOGGER.debug(logs)
|
||||
assert 'res0: Int = 2' in logs
|
||||
|
||||
|
||||
def test_pyspark(container):
|
||||
"""PySpark should be in the Python path"""
|
||||
c = container.run(
|
||||
|
@@ -3,7 +3,6 @@
|
||||
|
||||
# Optional test with [Matplotlib Jupyter Integration](https://github.com/matplotlib/ipympl)
|
||||
# %matplotlib widget
|
||||
import matplotlib
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import os
|
||||
|
@@ -3,7 +3,6 @@
|
||||
|
||||
import logging
|
||||
|
||||
import pytest
|
||||
import os
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
@@ -15,7 +14,7 @@ def test_matplotlib(container):
|
||||
cont_data_dir = "/home/jovyan/data"
|
||||
test_file = "matplotlib_1.py"
|
||||
output_dir = "/tmp"
|
||||
LOGGER.info(f"Test that matplotlib is able to plot a graph and write it as an image ...")
|
||||
LOGGER.info("Test that matplotlib is able to plot a graph and write it as an image ...")
|
||||
command = "sleep infinity"
|
||||
running_container = container.run(
|
||||
volumes={host_data_dir: {"bind": cont_data_dir, "mode": "ro"}},
|
||||
|
@@ -64,7 +64,7 @@ class CondaPackageHelper:
|
||||
def installed_packages(self):
|
||||
"""Return the installed packages"""
|
||||
if self.installed is None:
|
||||
LOGGER.info(f"Grabing the list of installed packages ...")
|
||||
LOGGER.info("Grabing the list of installed packages ...")
|
||||
self.installed = CondaPackageHelper._packages_from_json(
|
||||
self._execute_command(CondaPackageHelper._conda_export_command())
|
||||
)
|
||||
@@ -73,7 +73,7 @@ class CondaPackageHelper:
|
||||
def specified_packages(self):
|
||||
"""Return the specifications (i.e. packages installation requested)"""
|
||||
if self.specs is None:
|
||||
LOGGER.info(f"Grabing the list of specifications ...")
|
||||
LOGGER.info("Grabing the list of specifications ...")
|
||||
self.specs = CondaPackageHelper._packages_from_json(
|
||||
self._execute_command(CondaPackageHelper._conda_export_command(True))
|
||||
)
|
||||
@@ -87,11 +87,11 @@ class CondaPackageHelper:
|
||||
@staticmethod
|
||||
def _packages_from_json(env_export):
|
||||
"""Extract packages and versions from the lines returned by the list of specifications"""
|
||||
#dependencies = filter(lambda x: isinstance(x, str), json.loads(env_export).get("dependencies"))
|
||||
# dependencies = filter(lambda x: isinstance(x, str), json.loads(env_export).get("dependencies"))
|
||||
dependencies = json.loads(env_export).get("dependencies")
|
||||
# Filtering packages installed through pip in this case it's a dict {'pip': ['toree==0.3.0']}
|
||||
# Since we only manage packages installed through conda here
|
||||
dependencies = filter(lambda x: isinstance(x, str), dependencies)
|
||||
dependencies = filter(lambda x: isinstance(x, str), dependencies)
|
||||
packages_dict = dict()
|
||||
for split in map(lambda x: x.split("=", 1), dependencies):
|
||||
# default values
|
||||
@@ -112,7 +112,7 @@ class CondaPackageHelper:
|
||||
"""Return the available packages"""
|
||||
if self.available is None:
|
||||
LOGGER.info(
|
||||
f"Grabing the list of available packages (can take a while) ..."
|
||||
"Grabing the list of available packages (can take a while) ..."
|
||||
)
|
||||
# Keeping command line output since `conda search --outdated --json` is way too long ...
|
||||
self.available = CondaPackageHelper._extract_available(
|
||||
@@ -135,7 +135,7 @@ class CondaPackageHelper:
|
||||
installed = self.installed_packages()
|
||||
available = self.available_packages()
|
||||
self.comparison = list()
|
||||
for pkg, inst_vs in self.installed.items():
|
||||
for pkg, inst_vs in installed.items():
|
||||
if not specifications_only or pkg in specs:
|
||||
avail_vs = sorted(
|
||||
list(available[pkg]), key=CondaPackageHelper.semantic_cmp
|
||||
@@ -158,7 +158,8 @@ class CondaPackageHelper:
|
||||
"""Manage semantic versioning for comparison"""
|
||||
|
||||
def mysplit(string):
|
||||
version_substrs = lambda x: re.findall(r"([A-z]+|\d+)", x)
|
||||
def version_substrs(x):
|
||||
return re.findall(r"([A-z]+|\d+)", x)
|
||||
return list(chain(map(version_substrs, string.split("."))))
|
||||
|
||||
def str_ord(string):
|
||||
|
@@ -131,7 +131,7 @@ def _import_packages(package_helper, filtered_packages, check_function, max_fail
|
||||
Note: using a list of packages instead of a fixture for the list of packages since pytest prevents use of multiple yields
|
||||
"""
|
||||
failures = {}
|
||||
LOGGER.info(f"Testing the import of packages ...")
|
||||
LOGGER.info("Testing the import of packages ...")
|
||||
for package in filtered_packages:
|
||||
LOGGER.info(f"Trying to import {package}")
|
||||
try:
|
||||
|
Reference in New Issue
Block a user