Skip to content

Commit

Permalink
[Requirements] Bump black to stable version (#1745)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hedingber committed Feb 21, 2022
1 parent 4b99f57 commit 3b88658
Show file tree
Hide file tree
Showing 194 changed files with 3,140 additions and 1,145 deletions.
44 changes: 31 additions & 13 deletions automation/package_test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def __init__(self):
}

def run(self):
self._logger.info("Running package tests",)
self._logger.info(
"Running package tests",
)

results = {}
for extra, extra_tests_data in self._extras_tests_data.items():
Expand Down Expand Up @@ -84,13 +86,15 @@ def _run_test(self, test_function, extra, results, test_key):

def _test_extra_imports(self, extra):
self._logger.debug(
"Testing extra imports", extra=extra,
"Testing extra imports",
extra=extra,
)
test_command = (
f"python -c '{self._extras_tests_data[extra]['import_test_command']}'"
)
self._run_command(
test_command, run_in_venv=True,
test_command,
run_in_venv=True,
)
if "api" not in extra:
# When api is not in the extra it's an extra purposed for the client usage
Expand All @@ -104,33 +108,47 @@ def _test_extra_imports(self, extra):

def _test_requirements_conflicts(self, extra):
self._logger.debug(
"Testing requirements conflicts", extra=extra,
"Testing requirements conflicts",
extra=extra,
)
self._run_command(
"pip install pipdeptree", run_in_venv=True,
"pip install pipdeptree",
run_in_venv=True,
)
self._run_command(
"pipdeptree --warn fail", run_in_venv=True,
"pipdeptree --warn fail",
run_in_venv=True,
)

def _create_venv(self):
self._logger.debug("Creating venv",)
self._run_command("python -m venv test-venv",)
self._logger.debug(
"Creating venv",
)
self._run_command(
"python -m venv test-venv",
)

def _clean_venv(self):
self._logger.debug("Cleaning venv",)
self._run_command("rm -rf test-venv",)
self._logger.debug(
"Cleaning venv",
)
self._run_command(
"rm -rf test-venv",
)

def _install_extra(self, extra):
self._logger.debug(
"Installing extra", extra=extra,
"Installing extra",
extra=extra,
)
self._run_command(
"python -m pip install --upgrade pip~=22.0.0", run_in_venv=True,
"python -m pip install --upgrade pip~=22.0.0",
run_in_venv=True,
)

self._run_command(
f"pip install '.{extra}'", run_in_venv=True,
f"pip install '.{extra}'",
run_in_venv=True,
)

def _run_command(self, command, run_in_venv=False, env=None):
Expand Down
9 changes: 7 additions & 2 deletions automation/release_notes/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ class ReleaseNotesGenerator:
)

def __init__(
self, release: str, previous_release: str, release_branch: str,
self,
release: str,
previous_release: str,
release_branch: str,
):
self._logger = logger
self._release = release
Expand Down Expand Up @@ -217,7 +220,9 @@ def main():
@click.argument("previous-release", type=str, required=True)
@click.argument("release-branch", type=str, required=False, default="master")
def run(
release: str, previous_release: str, release_branch: str,
release: str,
previous_release: str,
release_branch: str,
):
release_notes_generator = ReleaseNotesGenerator(
release, previous_release, release_branch
Expand Down
2 changes: 1 addition & 1 deletion automation/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
click~=7.0
click~=8.0
paramiko~=2.7
semver~=2.13
requests~=2.22
11 changes: 8 additions & 3 deletions automation/system_test/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,17 @@ def extract_version_from_release(release):
def _prepare_test_env(self):

self._run_command(
"mkdir", args=["-p", str(self.Constants.workdir)],
"mkdir",
args=["-p", str(self.Constants.workdir)],
)
contents = yaml.safe_dump(self._env_config)
filepath = str(self.Constants.system_tests_env_yaml)
self._logger.debug("Populating system tests env.yml", filepath=filepath)
self._run_command(
"cat > ", args=[filepath], stdin=contents, local=True,
"cat > ",
args=[filepath],
stdin=contents,
local=True,
)

def _override_mlrun_api_env(self):
Expand Down Expand Up @@ -326,7 +330,8 @@ def _override_mlrun_api_env(self):
)

self._run_command(
"kubectl", args=["apply", "-f", manifest_file_name],
"kubectl",
args=["apply", "-f", manifest_file_name],
)

def _download_provctl(self):
Expand Down
11 changes: 9 additions & 2 deletions automation/version/version_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,18 @@ def _run_command(command, args=None):

if sys.version_info[0] >= 3:
process = subprocess.run(
command, shell=True, check=True, capture_output=True, encoding="utf-8",
command,
shell=True,
check=True,
capture_output=True,
encoding="utf-8",
)
output = process.stdout
else:
output = subprocess.check_output(command, shell=True,)
output = subprocess.check_output(
command,
shell=True,
)

return output

Expand Down
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pytest~=5.4
twine~=3.1
# TODO: bump black when it become stable
black<=19.10b0
black~=22.0
flake8~=3.8
pytest-asyncio~=0.15.0
pytest-alembic~=0.4.0
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/mlrun-api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
uvicorn~=0.12.0
uvicorn~=0.17.0
dask-kubernetes~=0.11.0
apscheduler~=3.6
sqlite3-to-mysql~=1.4
24 changes: 16 additions & 8 deletions mlrun/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def main():
@click.option(
"--param",
"-p",
default="",
default=[],
multiple=True,
help="parameter name and value tuples, e.g. -p x=37 -p y='text'",
)
Expand All @@ -81,7 +81,10 @@ def main():
@click.option("--in-path", help="default input path/url (prefix) for artifact")
@click.option("--out-path", help="default output path/url (prefix) for artifact")
@click.option(
"--secrets", "-s", multiple=True, help="secrets file=<filename> or env=ENV_KEY1,.."
"--secrets",
"-s",
multiple=True,
help="secrets file=<filename> or env=ENV_KEY1,..",
)
@click.option("--uid", help="unique run ID")
@click.option("--name", help="run name")
Expand All @@ -97,7 +100,7 @@ def main():
@click.option(
"--hyperparam",
"-x",
default="",
default=[],
multiple=True,
help="hyper parameters (will expand to multiple tasks) e.g. --hyperparam p2=[1,2,3]",
)
Expand All @@ -115,7 +118,9 @@ def main():
help="hyperparam tuning strategy list | grid | random",
)
@click.option(
"--hyper-param-options", default="", help="hyperparam options json string",
"--hyper-param-options",
default="",
help="hyperparam options json string",
)
@click.option(
"--func-url",
Expand Down Expand Up @@ -379,7 +384,7 @@ def run(
@click.option(
"--command",
"-c",
default="",
default=[],
multiple=True,
help="build commands, e.g. '-c pip install pandas'",
)
Expand Down Expand Up @@ -774,20 +779,23 @@ def logs(uid, project, offset, db, watch):
@click.option(
"--arguments",
"-a",
default="",
default=[],
multiple=True,
help="Kubeflow pipeline arguments name and value tuples (with -r flag), e.g. -a x=6",
)
@click.option("--artifact-path", "-p", help="output artifacts path")
@click.option(
"--param",
"-x",
default="",
default=[],
multiple=True,
help="mlrun project parameter name and value tuples, e.g. -p x=37 -p y='text'",
)
@click.option(
"--secrets", "-s", multiple=True, help="secrets file=<filename> or env=ENV_KEY1,.."
"--secrets",
"-s",
multiple=True,
help="secrets file=<filename> or env=ENV_KEY1,..",
)
@click.option("--namespace", help="k8s namespace")
@click.option("--db", help="api and db service path/url")
Expand Down
13 changes: 10 additions & 3 deletions mlrun/api/api/endpoints/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,19 @@ def list_artifact_tags(
db_session: Session = Depends(deps.get_db_session),
):
mlrun.api.utils.auth.verifier.AuthVerifier().query_project_permissions(
project, mlrun.api.schemas.AuthorizationAction.read, auth_info,
project,
mlrun.api.schemas.AuthorizationAction.read,
auth_info,
)
tag_tuples = get_db().list_artifact_tags(db_session, project)
artifact_key_to_tag = {tag_tuple[1]: tag_tuple[2] for tag_tuple in tag_tuples}
allowed_artifact_keys = mlrun.api.utils.auth.verifier.AuthVerifier().filter_project_resources_by_permissions(
mlrun.api.schemas.AuthorizationResourceTypes.artifact,
list(artifact_key_to_tag.keys()),
lambda artifact_key: (project, artifact_key,),
lambda artifact_key: (
project,
artifact_key,
),
auth_info,
)
tags = [
Expand Down Expand Up @@ -150,7 +155,9 @@ def list_artifacts(
if project is None:
project = config.default_project
mlrun.api.utils.auth.verifier.AuthVerifier().query_project_permissions(
project, mlrun.api.schemas.AuthorizationAction.read, auth_info,
project,
mlrun.api.schemas.AuthorizationAction.read,
auth_info,
)

artifacts = mlrun.api.crud.Artifacts().list_artifacts(
Expand Down
3 changes: 2 additions & 1 deletion mlrun/api/api/endpoints/background_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def get_project_background_task(


@router.get(
"/background-tasks/{name}", response_model=mlrun.api.schemas.BackgroundTask,
"/background-tasks/{name}",
response_model=mlrun.api.schemas.BackgroundTask,
)
def get_background_task(
name: str,
Expand Down
3 changes: 2 additions & 1 deletion mlrun/api/api/endpoints/client_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@


@router.get(
"/client-spec", response_model=mlrun.api.schemas.ClientSpec,
"/client-spec",
response_model=mlrun.api.schemas.ClientSpec,
)
def get_client_spec():
return mlrun.api.crud.ClientSpec().get_client_spec()

0 comments on commit 3b88658

Please sign in to comment.