diff --git a/.github/workflows/goth-nightly.yml b/.github/workflows/goth-nightly.yml index 61528e4a3..2c02445e7 100644 --- a/.github/workflows/goth-nightly.yml +++ b/.github/workflows/goth-nightly.yml @@ -38,30 +38,29 @@ jobs: fail-fast: false name: Run integration tests (nightly) on ${{ matrix.branch }} steps: + - name: install docker-compose + run: | + sudo curl -L "https://github.com/docker/compose/releases/download/1.28.4/docker-compose-Linux-x86_64" -o /usr/local/bin/docker-compose + sudo chmod a+x /usr/local/bin/docker-compose + + - name: install ffi + run: sudo apt-get install libffi-dev + - name: Checkout uses: actions/checkout@v3 - with: - ref: ${{ matrix.branch }} - name: Configure python uses: actions/setup-python@v4 with: python-version: '3.8.0' - - name: Configure poetry - uses: Gr1N/setup-poetry@v8 - with: - poetry-version: 1.2.2 + - name: Install and configure Poetry + run: python -m pip install -U pip setuptools poetry==1.3.2 - name: Install dependencies run: | poetry env use python3.8 - poetry install -E integration-tests - - - name: Install websocat - run: | - sudo wget https://github.com/vi/websocat/releases/download/v1.9.0/websocat_linux64 -O /usr/local/bin/websocat - sudo chmod +x /usr/local/bin/websocat + poetry install - name: Disconnect Docker containers from default network continue-on-error: true @@ -82,19 +81,20 @@ jobs: - name: Log in to GitHub Docker repository run: echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u ${{github.actor}} --password-stdin + - name: Initialize the test suite + run: poetry run poe tests_integration_init + - name: Run test suite env: GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - poetry run poe tests_integration_assets - poetry run poe tests_integration + run: poetry run poe tests_integration - name: Upload test logs uses: actions/upload-artifact@v2 if: always() with: - name: goth-logs - path: /tmp/goth-tests + name: goth-logs + path: /tmp/goth-tests # Only relevant for self-hosted runners - name: Remove test logs diff --git a/.github/workflows/goth.yml b/.github/workflows/goth.yml index eaf77cd7b..7d8e677d7 100644 --- a/.github/workflows/goth.yml +++ b/.github/workflows/goth.yml @@ -16,6 +16,14 @@ jobs: name: Run integration tests runs-on: [goth, ubuntu-18.04] steps: + - name: install docker-compose + run: | + sudo curl -L "https://github.com/docker/compose/releases/download/1.28.4/docker-compose-Linux-x86_64" -o /usr/local/bin/docker-compose + sudo chmod a+x /usr/local/bin/docker-compose + + - name: install ffi + run: sudo apt-get install libffi-dev + - name: Checkout uses: actions/checkout@v3 @@ -24,15 +32,13 @@ jobs: with: python-version: '3.8.0' - - name: Configure poetry - uses: Gr1N/setup-poetry@v8 - with: - poetry-version: 1.2.2 + - name: Install and configure Poetry + run: python -m pip install -U pip setuptools poetry==1.3.2 - name: Install dependencies run: | poetry env use python3.8 - poetry install -E integration-tests + poetry install - name: Disconnect Docker containers from default network continue-on-error: true @@ -53,12 +59,13 @@ jobs: - name: Log in to GitHub Docker repository run: echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u ${{github.actor}} --password-stdin + - name: Initialize the test suite + run: poetry run poe tests_integration_init + - name: Run test suite env: GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - poetry run poe tests_integration_assets - poetry run poe tests_integration + run: poetry run poe tests_integration - name: Upload test logs uses: actions/upload-artifact@v2 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 30a845e17..fe0ce05f9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10"] + python-version: ["3.8", "3.9", "3.10"] os: - ubuntu-latest - macos-latest diff --git a/docs/sphinx/conf.py b/docs/sphinx/conf.py index ecb7b112d..2ff64f1ca 100644 --- a/docs/sphinx/conf.py +++ b/docs/sphinx/conf.py @@ -59,6 +59,7 @@ # so a file named "default.css" will overwrite the builtin "default.css". html_static_path: List[str] = [] + # This removes the `yapapi.log` docstrings. # There are two reasons: # * there are some sections/subsections declared there and it messes up the docs diff --git a/examples/custom-usage-counter/custom_usage_counter.py b/examples/custom-usage-counter/custom_usage_counter.py index 49a7224c6..2e5264f51 100755 --- a/examples/custom-usage-counter/custom_usage_counter.py +++ b/examples/custom-usage-counter/custom_usage_counter.py @@ -55,7 +55,6 @@ async def shutdown(self): async def main(running_time_sec, subnet_tag, driver=None, network=None): - # necessary to set maximum price for one unit of custom counter, # default strategy does not take custom counter prices into account strategy = LeastExpensiveLinearPayuMS( diff --git a/examples/custom_runtime/custom_runtime.py b/examples/custom_runtime/custom_runtime.py index 8d57b0e4f..1696f60b6 100644 --- a/examples/custom_runtime/custom_runtime.py +++ b/examples/custom_runtime/custom_runtime.py @@ -38,7 +38,6 @@ async def get_payload(): async def main(subnet_tag, driver=None, network=None): - async with Golem( budget=10.0, subnet_tag=subnet_tag, diff --git a/pyproject.toml b/pyproject.toml index 4596bec83..9b45e5709 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,18 +19,17 @@ requires = ["poetry_core>=1.0.0"] build-backend = "poetry.core.masonry.api" [tool.poetry.dependencies] -python = "^3.6.2" +python = "^3.8" setuptools = [ - { version = "*", python = ">=3.7" }, - { version = "^59.0.0", python = ">=3.6.2, <3.7" }, + { version = "*", python = ">=3.8" }, ] aiohttp = "^3.6" aiohttp-sse-client = "^0.1.7" dataclasses = { version = "^0.8", python = ">=3.6, <3.7" } more-itertools = "^8.6.0" urllib3 = "^1.25.9" -typing_extensions = "^3.10.0" +typing-extensions = "^4.5.0" async_exit_stack = "^1.0.1" jsonrpc-base = "^1.0.3" @@ -42,28 +41,15 @@ colorama = "^0.4.4" semantic-version = "^2.8" attrs = ">=19.3" -# Adding `goth` to dependencies causes > 40 additional packages to be installed. Given -# that dependency resolution in `poetry` is rather slow, we'd like to avoid installing -# `goth` for example in a CI pipeline that only runs linters/unit tests, not integration -# tests. Therefore we specify `goth` as an "extra" dependency, with `optional = "true"`. -# It will be then installable with `poetry install -E integration-tests`. -# Note that putting `goth` in `poetry.dev-dependencies` instead of `poetry.dependencies` -# would not work: see https://github.com/python-poetry/poetry/issues/129. -goth = { version = "^0.14", optional = true, python = "^3.8.0" } -# goth = { git = "https://github.com/golemfactory/goth.git", branch = "master", optional = true, python = "^3.8.0", develop = true } Deprecated = "^1.2.12" python-statemachine = "^0.8.0" -# goth tests -pexpect = { version = "^4.8.0", optional = true } - # Docs sphinx = { version = "^4.0.1", optional = true } sphinx-autodoc-typehints = { version = "^1.12.0", optional = true } sphinx-rtd-theme = { version = "^1.0.0", optional = true } [tool.poetry.extras] -integration-tests = ['goth', 'pytest', 'pytest-asyncio', 'pexpect'] docs = ['sphinx', 'sphinx-autodoc-typehints', 'sphinx-rtd-theme'] [tool.poetry.group.dev.dependencies] @@ -71,7 +57,7 @@ pip = [ { version = "*", python = ">=3.7" }, { version = "^21.0.0", python = ">=3.6.2, <3.7" }, ] -black = "^21.7b0" +black = "^23.1.0" factory-boy = "^3.2.0" isort = "^5.10.1" liccheck = "^0.4.7" @@ -97,14 +83,19 @@ checks_typing = {cmd = "mypy .", help = "Run only code typing checks" } checks_license = {sequence = ["_checks_license_export", "_checks_license_verify"], help = "Run only license compatibility checks"} _checks_license_export = "poetry export -f requirements.txt -o .requirements.txt" _checks_license_verify = "liccheck -r .requirements.txt" + format = {sequence = ["_format_autoflake", "_format_isort", "_format_black"], help = "Run code auto formatting"} _format_autoflake = "pautoflake ." _format_isort = "isort ." _format_black = "black ." -tests = {sequence = ["tests_unit", "tests_integration"], help = "Run all available tests"} + tests_unit = {cmd = "pytest --cov=yapapi --cov-report html --cov-report term -sv --ignore tests/goth_tests", help = "Run only unit tests"} -tests_integration = {cmd = "pytest -svx tests/goth_tests --config-override docker-compose.build-environment.use-prerelease=true --config-path tests/goth_tests/assets/goth-config-testing.yml --ssh-verify-connection --reruns 3 --only-rerun AssertionError --only-rerun TimeoutError --only-rerun goth.runner.exceptions.TemporalAssertionError --only-rerun urllib.error.URLError --only-rerun goth.runner.exceptions.CommandError", help = "Run only integration tests"} -tests_integration_assets = {cmd = "python -m goth create-assets tests/goth_tests/assets", help = "Generate assets files for integration tests"} +tests_integration_init = { sequence = ["_gothv_env", "_gothv_requirements", "_gothv_assets"], help="Initialize the integration test environment"} +tests_integration = { cmd = ".envs/yapapi-goth/bin/python -m pytest -svx tests/goth_tests --config-override docker-compose.build-environment.use-prerelease=false --config-path tests/goth_tests/assets/goth-config.yml --ssh-verify-connection --reruns 3 --only-rerun AssertionError --only-rerun TimeoutError --only-rerun goth.runner.exceptions.TemporalAssertionError --only-rerun urllib.error.URLError --only-rerun goth.runner.exceptions.CommandError", help = "Run the integration tests"} +_gothv_env = "python -m venv .envs/yapapi-goth" +_gothv_requirements = ".envs/yapapi-goth/bin/pip install -U --extra-index-url https://test.pypi.org/simple/ goth==0.14.1 pip pytest pytest-asyncio pytest-rerunfailures pexpect" +_gothv_assets = ".envs/yapapi-goth/bin/python -m goth create-assets tests/goth_tests/assets" + clean = {cmd = "rm -rf .coverage .requirements.txt dist md handbook build", help = "Clean all development related files" } clean_examples = {sequence = ["clean_examples_blender", "clean_examples_hello", "clean_examples_http_proxy", "clean_examples_simple_service", "clean_examples_ssh", "clean_examples_webapp", "clean_examples_yacat"], help = "Clean all example related files"} clean_examples_blender = {cmd = "rm -f examples/blender/*.png examples/blender/*.log", help = "Clean \"blender\" example related files"} @@ -114,6 +105,7 @@ clean_examples_simple_service = {cmd = "rm -f examples/simple-service-poc/*.png clean_examples_ssh = {cmd = "rm -f examples/ssh/*.log", help = "Clean \"ssh\" example related files"} clean_examples_webapp = {cmd = "rm -f examples/webapp/*.log", help = "Clean \"webapp\" example related files"} clean_examples_yacat = {cmd = "rm -f examples/yacat/*.log", help = "Clean \"yacat\" example related files"} + sphinx = {cmd = "sphinx-build docs/sphinx/ build -E", help = "Build Sphinx docs"} [tool.liccheck.authorized_packages] diff --git a/tests/conftest.py b/tests/conftest.py index 03cf5850c..d2a971b35 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,7 +4,6 @@ def pytest_addoption(parser): - parser.addoption("--ya-api-key", type=str, help="instance api key", dest="yaApiKey") diff --git a/tests/drone/drone.py b/tests/drone/drone.py index e03dc84a8..0d2e79ce6 100755 --- a/tests/drone/drone.py +++ b/tests/drone/drone.py @@ -59,7 +59,6 @@ async def worker(ctx: WorkContext, tasks): payment_driver=payment_driver, payment_network=payment_network, ) as golem: - print( f"yapapi version: {TEXT_COLOR_YELLOW}{yapapi_version}{TEXT_COLOR_DEFAULT}\n" f"Using subnet: {TEXT_COLOR_YELLOW}{subnet_tag}{TEXT_COLOR_DEFAULT}, " diff --git a/tests/executor/test_smartq.py b/tests/executor/test_smartq.py index bb42ec48a..8bc6639b5 100644 --- a/tests/executor/test_smartq.py +++ b/tests/executor/test_smartq.py @@ -16,7 +16,6 @@ async def async_iter(iterable): @pytest.mark.asyncio @pytest.mark.parametrize("length", [0, 1, 100]) async def test_smart_queue(length: int): - q = SmartQueue(async_iter(range(length))) async def worker(i, queue): @@ -54,7 +53,6 @@ async def stats(): @pytest.mark.asyncio async def test_smart_queue_empty(): - q: SmartQueue = SmartQueue(async_iter([])) with q.new_consumer() as c: async for _item in c: diff --git a/tests/goth_tests/test_resubscription.py b/tests/goth_tests/___test_resubscription.py similarity index 99% rename from tests/goth_tests/test_resubscription.py rename to tests/goth_tests/___test_resubscription.py index 9f773e0b0..4109eb2cc 100644 --- a/tests/goth_tests/test_resubscription.py +++ b/tests/goth_tests/___test_resubscription.py @@ -138,7 +138,6 @@ async def test_demand_resubscription( runner = Runner(base_log_dir=log_dir, compose_config=goth_config.compose_config) async with runner(goth_config.containers): - requestor = runner.get_probes(probe_type=RequestorProbe)[0] env = dict(os.environ) env.update(requestor.get_agent_env_vars()) @@ -166,7 +165,6 @@ async def worker(work_ctx, tasks): budget=10.0, event_consumer=monitor.add_event_sync, ) as golem: - task: Task # mypy needs this for some reason async for task in golem.execute_tasks( worker, diff --git a/tests/goth_tests/conftest.py b/tests/goth_tests/conftest.py index ee50b6642..35e88a76f 100644 --- a/tests/goth_tests/conftest.py +++ b/tests/goth_tests/conftest.py @@ -7,8 +7,6 @@ from goth.configuration import Override -from yapapi.payload import vm - # `pytest-rerunfailures` and `pytest-asyncio` don't work together # (https://github.com/pytest-dev/pytest-rerunfailures/issues/154) @@ -112,15 +110,3 @@ def log_dir() -> Path: @pytest.fixture(scope="session") def goth_config_path(request) -> Path: return request.config.option.config_path - - -@pytest.fixture() -def blender_vm_package(): - async def coro(): - return await vm.repo( - image_hash="9a3b5d67b0b27746283cb5f287c13eab1beaa12d92a9f536b747c7ae", - min_mem_gib=0.5, - min_storage_gib=2.0, - ) - - return coro() diff --git a/tests/goth_tests/test_agreement_termination/requestor.py b/tests/goth_tests/test_agreement_termination/requestor.py index d98a5b26d..40b8922b8 100755 --- a/tests/goth_tests/test_agreement_termination/requestor.py +++ b/tests/goth_tests/test_agreement_termination/requestor.py @@ -10,7 +10,6 @@ async def main(): - package = await vm.repo( image_hash="9a3b5d67b0b27746283cb5f287c13eab1beaa12d92a9f536b747c7ae", min_mem_gib=0.5, @@ -36,7 +35,6 @@ async def worker(ctx: WorkContext, tasks): first_worker = False async for task in tasks: - script = ctx.new_script() if should_fail: @@ -54,7 +52,6 @@ async def worker(ctx: WorkContext, tasks): budget=10.0, subnet_tag="goth", ) as golem: - tasks = [Task(data=n) for n in range(6)] async for task in golem.execute_tasks( worker, @@ -69,7 +66,6 @@ async def worker(ctx: WorkContext, tasks): if __name__ == "__main__": - enable_default_logger(log_file="test.log") console_handler = logging.StreamHandler() diff --git a/tests/goth_tests/test_agreement_termination/test_agreement_termination.py b/tests/goth_tests/test_agreement_termination/test_agreement_termination.py index e5674787d..91cf1a802 100644 --- a/tests/goth_tests/test_agreement_termination/test_agreement_termination.py +++ b/tests/goth_tests/test_agreement_termination/test_agreement_termination.py @@ -64,7 +64,6 @@ async def test_agreement_termination( goth_config_path: Path, config_overrides: List[Override], ) -> None: - # This is the default configuration with 2 wasm/VM providers goth_config = load_yaml(goth_config_path, config_overrides) test_script_path = str(Path(__file__).parent / "requestor.py") @@ -77,7 +76,6 @@ async def test_agreement_termination( ) async with runner(goth_config.containers): - requestor = runner.get_probes(probe_type=RequestorProbe)[0] async with requestor.run_command_on_host(test_script_path, env=os.environ) as ( @@ -85,7 +83,6 @@ async def test_agreement_termination( cmd_monitor, _process_monitor, ): - cmd_monitor.add_assertion(assert_all_tasks_computed) # Wait for worker failure due to command error diff --git a/tests/goth_tests/test_async_task_generation/requestor.py b/tests/goth_tests/test_async_task_generation/requestor.py index 996842a96..ef9cd9674 100755 --- a/tests/goth_tests/test_async_task_generation/requestor.py +++ b/tests/goth_tests/test_async_task_generation/requestor.py @@ -11,7 +11,6 @@ async def main(): - vm_package = await vm.repo( image_hash="9a3b5d67b0b27746283cb5f287c13eab1beaa12d92a9f536b747c7ae", min_mem_gib=0.5, @@ -31,7 +30,6 @@ async def worker(work_ctx, tasks): subnet_tag="goth", event_consumer=log_event_repr, ) as golem: - # We use an async task generator that yields tasks removed from # an async queue. Each computed task will potentially spawn # new tasks -- this is made possible thanks to using async task diff --git a/tests/goth_tests/test_async_task_generation/test_async_task_generation.py b/tests/goth_tests/test_async_task_generation/test_async_task_generation.py index 556e1ba41..8f2c21a34 100644 --- a/tests/goth_tests/test_async_task_generation/test_async_task_generation.py +++ b/tests/goth_tests/test_async_task_generation/test_async_task_generation.py @@ -32,7 +32,6 @@ async def test_async_task_generation( runner = Runner(base_log_dir=log_dir, compose_config=goth_config.compose_config) async with runner(goth_config.containers): - requestor = runner.get_probes(probe_type=RequestorProbe)[0] async with requestor.run_command_on_host( diff --git a/tests/goth_tests/test_concurrent_executors/requestor.py b/tests/goth_tests/test_concurrent_executors/requestor.py index 375eb7fcf..9ea542d8a 100755 --- a/tests/goth_tests/test_concurrent_executors/requestor.py +++ b/tests/goth_tests/test_concurrent_executors/requestor.py @@ -15,7 +15,6 @@ async def main(): - vm_package = await vm.repo( image_hash="9a3b5d67b0b27746283cb5f287c13eab1beaa12d92a9f536b747c7ae", min_mem_gib=0.5, @@ -35,7 +34,6 @@ async def duplicator(work_ctx, tasks): failures. """ async for task in tasks: - nonlocal first_task script = work_ctx.new_script() @@ -53,7 +51,6 @@ async def duplicator(work_ctx, tasks): task.accept_result(output) async with Golem(budget=1.0, subnet_tag="goth") as golem: - # Construct a pipeline: # # input_tasks diff --git a/tests/goth_tests/test_concurrent_executors/test_concurrent_executors.py b/tests/goth_tests/test_concurrent_executors/test_concurrent_executors.py index 9eee5f732..2e22adaac 100644 --- a/tests/goth_tests/test_concurrent_executors/test_concurrent_executors.py +++ b/tests/goth_tests/test_concurrent_executors/test_concurrent_executors.py @@ -30,13 +30,11 @@ async def test_concurrent_executors( runner = Runner(base_log_dir=log_dir, compose_config=goth_config.compose_config) async with runner(goth_config.containers): - requestor = runner.get_probes(probe_type=RequestorProbe)[0] async with requestor.run_command_on_host( str(Path(__file__).parent / "requestor.py"), env=os.environ ) as (_cmd_task, cmd_monitor, _process_monitor): - # Wait for job ALEF summary await cmd_monitor.wait_for_pattern(".*ALEF.* Job finished", timeout=60) await cmd_monitor.wait_for_pattern(".*ALEF.* Negotiated 2 agreements", timeout=5) diff --git a/tests/goth_tests/test_instance_restart/requestor.py b/tests/goth_tests/test_instance_restart/requestor.py index 61ba97318..9663c1265 100755 --- a/tests/goth_tests/test_instance_restart/requestor.py +++ b/tests/goth_tests/test_instance_restart/requestor.py @@ -34,7 +34,6 @@ async def get_payload(): ) async def start(self): - global instances_started async for script in super().start(): @@ -58,7 +57,6 @@ async def start(self): await asyncio.sleep(30) async def run(self): - global instances_running instances_running += 1 @@ -74,7 +72,6 @@ async def run(self): await future_result async def shutdown(self): - global instances_stopped log("STOPPING", instances_started) @@ -84,9 +81,7 @@ async def shutdown(self): async def main(): - async with Golem(budget=1.0, subnet_tag="goth") as golem: - # Start a cluster with a single service. # The first instance will fail before reaching the `running` state # due to an error. Another instance should be spawned in its place. diff --git a/tests/goth_tests/test_instance_restart/test_instance_restart.py b/tests/goth_tests/test_instance_restart/test_instance_restart.py index 011d68805..ffc1ba5fc 100644 --- a/tests/goth_tests/test_instance_restart/test_instance_restart.py +++ b/tests/goth_tests/test_instance_restart/test_instance_restart.py @@ -52,13 +52,11 @@ async def test_instance_restart( runner = Runner(base_log_dir=log_dir, compose_config=goth_config.compose_config) async with runner(goth_config.containers): - requestor = runner.get_probes(probe_type=RequestorProbe)[0] async with requestor.run_command_on_host( str(Path(__file__).parent / "requestor.py"), env=os.environ ) as (_cmd_task, cmd_monitor, _process_monitor): - cmd_monitor.add_assertion(count_instances) # The first attempt to create an instance should fail diff --git a/tests/goth_tests/test_mid_agreement_payments/requestor_agent.py b/tests/goth_tests/test_mid_agreement_payments/requestor_agent.py index 551aa8025..f4e05b4b3 100755 --- a/tests/goth_tests/test_mid_agreement_payments/requestor_agent.py +++ b/tests/goth_tests/test_mid_agreement_payments/requestor_agent.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +import argparse import asyncio import logging from datetime import timedelta @@ -51,7 +52,13 @@ async def main(): if __name__ == "__main__": - enable_default_logger(log_file="mid_agreement_payments.log") + parser = argparse.ArgumentParser() + parser.add_argument( + "--log-file", + default=str("mid_agreement_payments.log"), + ) + args = parser.parse_args() + enable_default_logger(log_file=args.log_file) loop = asyncio.get_event_loop() task = loop.create_task(main()) diff --git a/tests/goth_tests/test_mid_agreement_payments/test_mid_agreement_payments.py b/tests/goth_tests/test_mid_agreement_payments/test_mid_agreement_payments.py index 0a88614c3..21f65fef6 100644 --- a/tests/goth_tests/test_mid_agreement_payments/test_mid_agreement_payments.py +++ b/tests/goth_tests/test_mid_agreement_payments/test_mid_agreement_payments.py @@ -2,6 +2,7 @@ import logging import os import re +from datetime import datetime from pathlib import Path from typing import List, Optional @@ -13,9 +14,7 @@ from goth.runner.log import configure_logging from goth.runner.probe import RequestorProbe -from yapapi.strategy import DEBIT_NOTE_INTERVAL_GRACE_PERIOD - -from . import requestor_agent +DEBIT_NOTE_INTERVAL_GRACE_PERIOD = 30 logger = logging.getLogger("goth.test.mid_agreement_payments") @@ -52,6 +51,7 @@ async def assert_debit_note_freq(events: EventStream) -> str: @pytest.mark.asyncio async def test_mid_agreement_payments( + project_dir: Path, log_dir: Path, goth_config_path: Path, config_overrides: List[Override], @@ -60,12 +60,19 @@ async def test_mid_agreement_payments( # goth setup config = load_yaml(goth_config_path, config_overrides + [single_node_override]) configure_logging(log_dir) + + logfile = f"mid-agreement-payments-{datetime.now().strftime('%Y-%m-%d_%H.%M.%S')}.log" + + requestor_path = Path(__file__).parent / "requestor_agent.py" + runner = Runner(base_log_dir=log_dir, compose_config=config.compose_config) async with runner(config.containers): # given requestor = runner.get_probes(probe_type=RequestorProbe)[0] # when - async with requestor.run_command_on_host(requestor_agent.__file__, env=os.environ) as ( + async with requestor.run_command_on_host( + f"{requestor_path} --log-file {(log_dir / logfile).resolve()}", env=os.environ + ) as ( _, cmd_monitor, _, diff --git a/tests/goth_tests/test_multiactivity_agreement/requestor.py b/tests/goth_tests/test_multiactivity_agreement/requestor.py index ef1f1d78e..bb5197b9b 100755 --- a/tests/goth_tests/test_multiactivity_agreement/requestor.py +++ b/tests/goth_tests/test_multiactivity_agreement/requestor.py @@ -10,7 +10,6 @@ async def main(): - vm_package = await vm.repo( image_hash="9a3b5d67b0b27746283cb5f287c13eab1beaa12d92a9f536b747c7ae", min_mem_gib=0.5, @@ -43,7 +42,6 @@ async def worker(work_ctx, tasks): if __name__ == "__main__": - enable_default_logger() console_handler = logging.StreamHandler() console_handler.setLevel(logging.DEBUG) diff --git a/tests/goth_tests/test_multiactivity_agreement/test_multiactivity_agreement.py b/tests/goth_tests/test_multiactivity_agreement/test_multiactivity_agreement.py index 948674731..134b25b93 100644 --- a/tests/goth_tests/test_multiactivity_agreement/test_multiactivity_agreement.py +++ b/tests/goth_tests/test_multiactivity_agreement/test_multiactivity_agreement.py @@ -55,7 +55,6 @@ async def test_multiactivity_agreement( config_overrides: List[goth.configuration.Override], single_node_override: goth.configuration.Override, ) -> None: - configure_logging(log_dir) goth_config = goth.configuration.load_yaml( @@ -65,13 +64,11 @@ async def test_multiactivity_agreement( runner = Runner(base_log_dir=log_dir, compose_config=goth_config.compose_config) async with runner(goth_config.containers): - requestor = runner.get_probes(probe_type=RequestorProbe)[0] async with requestor.run_command_on_host( str(Path(__file__).parent / "requestor.py"), env=os.environ ) as (_cmd_task, cmd_monitor, _process_monitor): - # Wait for agreement assertion = cmd_monitor.add_assertion(assert_agreement_created) agr_id = await assertion.wait_for_result(timeout=30) diff --git a/tests/goth_tests/test_power_outage.py b/tests/goth_tests/test_power_outage.py index 72994283d..40103bb72 100644 --- a/tests/goth_tests/test_power_outage.py +++ b/tests/goth_tests/test_power_outage.py @@ -11,8 +11,6 @@ from goth.runner.log import configure_logging from goth.runner.probe import ProviderProbe, RequestorProbe -from yapapi.log import SummaryLogger - from .assertions import assert_no_errors, assert_tasks_processed logger = logging.getLogger("goth.test.power_outage") @@ -45,7 +43,6 @@ async def assert_all_tasks_computed(output_lines: EventStream[str]): async def test_power_outage( project_dir: Path, log_dir: Path, goth_config_path: Path, config_overrides: List[Override] ) -> None: - # This is the default configuration with 2 wasm/VM providers goth_config = load_yaml(goth_config_path, config_overrides) @@ -59,7 +56,6 @@ async def test_power_outage( ) async with runner(goth_config.containers): - requestor = runner.get_probes(probe_type=RequestorProbe)[0] provider_1 = runner.get_probes(probe_type=ProviderProbe)[0] @@ -69,7 +65,6 @@ async def test_power_outage( ), env=os.environ, ) as (_cmd_task, cmd_monitor, _process_monitor): - # Add assertions to the command output monitor `cmd_monitor`: cmd_monitor.add_assertion(assert_no_errors) all_sent = cmd_monitor.add_assertion(assert_all_tasks_started) @@ -104,8 +99,6 @@ async def test_power_outage( await cmd_monitor.wait_for_pattern(".*Unpaid agreements: .*") logger.info("Expected 1 unpaid agreement") - await cmd_monitor.wait_for_pattern( - f".*{SummaryLogger.GOLEM_SHUTDOWN_SUCCESSFUL_MESSAGE}", timeout=120 - ) + await cmd_monitor.wait_for_pattern(".*Golem engine has shut down", timeout=120) logger.info("Requestor script finished") diff --git a/tests/goth_tests/test_recycle_ip/test_recycle_ip.py b/tests/goth_tests/test_recycle_ip/test_recycle_ip.py index 8413c5884..07264fbd7 100644 --- a/tests/goth_tests/test_recycle_ip/test_recycle_ip.py +++ b/tests/goth_tests/test_recycle_ip/test_recycle_ip.py @@ -31,7 +31,6 @@ async def test_recycle_ip( config_overrides: List[Override], ssh_verify_connection: bool, ) -> None: - if ssh_verify_connection: ssh_check = pexpect.spawn("/usr/bin/which ssh") exit_code = ssh_check.wait() @@ -59,7 +58,6 @@ async def test_recycle_ip( ) async with runner(goth_config.containers): - requestor = runner.get_probes(probe_type=RequestorProbe)[0] async with requestor.run_command_on_host( diff --git a/tests/goth_tests/test_renegotiate_proposal/test_renegotiate_proposal.py b/tests/goth_tests/test_renegotiate_proposal/test_renegotiate_proposal.py index f19bdd016..523d8d140 100644 --- a/tests/goth_tests/test_renegotiate_proposal/test_renegotiate_proposal.py +++ b/tests/goth_tests/test_renegotiate_proposal/test_renegotiate_proposal.py @@ -19,7 +19,6 @@ async def test_renegotiation( goth_config_path: Path, config_overrides: List[Override], ) -> None: - # This is the default configuration with 2 wasm/VM providers goth_config = load_yaml(goth_config_path, config_overrides) test_script_path = str(Path(__file__).parent / "requestor.py") @@ -32,7 +31,6 @@ async def test_renegotiation( ) async with runner(goth_config.containers): - requestor = runner.get_probes(probe_type=RequestorProbe)[0] async with requestor.run_command_on_host(test_script_path, env=os.environ) as ( @@ -40,7 +38,6 @@ async def test_renegotiation( cmd_monitor, _process_monitor, ): - await cmd_monitor.wait_for_pattern(r"\[.+\] Renegotiating", timeout=50) await cmd_monitor.wait_for_pattern(r"agreement.terminate\(\): True", timeout=50) # assert not "Main timeout triggered :(" diff --git a/tests/goth_tests/test_run_blender.py b/tests/goth_tests/test_run_blender.py index 39e95c8f1..9574ec5c7 100644 --- a/tests/goth_tests/test_run_blender.py +++ b/tests/goth_tests/test_run_blender.py @@ -11,8 +11,6 @@ from goth.runner.log import configure_logging from goth.runner.probe import RequestorProbe -from yapapi.log import SummaryLogger - from .assertions import assert_all_invoices_accepted, assert_no_errors, assert_tasks_processed logger = logging.getLogger("goth.test.run_blender") @@ -38,7 +36,6 @@ async def assert_all_tasks_computed(output_lines: EventStream[str]): async def test_run_blender( project_dir: Path, log_dir: Path, goth_config_path: Path, config_overrides: List[Override] ) -> None: - # This is the default configuration with 2 wasm/VM providers goth_config = load_yaml(goth_config_path, config_overrides) @@ -52,14 +49,12 @@ async def test_run_blender( ) async with runner(goth_config.containers): - requestor = runner.get_probes(probe_type=RequestorProbe)[0] async with requestor.run_command_on_host( f"{blender_path} --subnet-tag goth --min-cpu-threads 1", env=os.environ, ) as (_cmd_task, cmd_monitor, _process_monitor): - # Add assertions to the command output monitor `cmd_monitor`: cmd_monitor.add_assertion(assert_no_errors) cmd_monitor.add_assertion(assert_all_invoices_accepted) @@ -81,8 +76,6 @@ async def test_run_blender( await all_computed.wait_for_result(timeout=120) logger.info("All tasks computed, waiting for Golem shutdown") - await cmd_monitor.wait_for_pattern( - f".*{SummaryLogger.GOLEM_SHUTDOWN_SUCCESSFUL_MESSAGE}", timeout=120 - ) + await cmd_monitor.wait_for_pattern(".*Golem engine has shut down", timeout=120) logger.info("Requestor script finished") diff --git a/tests/goth_tests/test_run_custom_usage_counter.py b/tests/goth_tests/test_run_custom_usage_counter.py index 1a57f10c2..03dfe6f2e 100644 --- a/tests/goth_tests/test_run_custom_usage_counter.py +++ b/tests/goth_tests/test_run_custom_usage_counter.py @@ -70,7 +70,6 @@ async def test_run_custom_usage_counter( goth_config_path: Path, config_overrides: List[Override], ) -> None: - configure_logging(log_dir) # This is the default configuration with 2 wasm/VM providers @@ -83,14 +82,12 @@ async def test_run_custom_usage_counter( ) async with runner(goth_config.containers): - requestor = runner.get_probes(probe_type=RequestorProbe)[0] async with requestor.run_command_on_host( f"{requestor_path} --running-time {RUNNING_TIME} --subnet-tag {SUBNET_TAG}", env=os.environ, ) as (_cmd_task, cmd_monitor, _process_monitor): - cmd_monitor.add_assertion(assert_no_errors) cmd_monitor.add_assertion(assert_all_invoices_accepted) diff --git a/tests/goth_tests/test_run_scan.py b/tests/goth_tests/test_run_scan.py index 1808da378..0adb1babf 100644 --- a/tests/goth_tests/test_run_scan.py +++ b/tests/goth_tests/test_run_scan.py @@ -28,7 +28,6 @@ async def test_run_scan( goth_config_path: Path, config_overrides: List[Override], ) -> None: - configure_logging(log_dir) # This is the default configuration with 2 wasm/VM providers @@ -42,7 +41,6 @@ async def test_run_scan( ) async with runner(goth_config.containers): - requestor = runner.get_probes(probe_type=RequestorProbe)[0] async with requestor.run_command_on_host( diff --git a/tests/goth_tests/test_run_simple_service.py b/tests/goth_tests/test_run_simple_service.py index 03e9902b7..ef72c2fc7 100644 --- a/tests/goth_tests/test_run_simple_service.py +++ b/tests/goth_tests/test_run_simple_service.py @@ -27,7 +27,6 @@ async def test_run_simple_service( goth_config_path: Path, config_overrides: List[Override], ) -> None: - configure_logging(log_dir) # This is the default configuration with 2 wasm/VM providers @@ -41,14 +40,12 @@ async def test_run_simple_service( ) async with runner(goth_config.containers): - requestor = runner.get_probes(probe_type=RequestorProbe)[0] async with requestor.run_command_on_host( f"{requestor_path} --running-time {RUNNING_TIME} --subnet-tag {SUBNET_TAG}", env=os.environ, ) as (_cmd_task, cmd_monitor, _process_monitor): - start_time = time.time() def elapsed_time(): diff --git a/tests/goth_tests/test_run_ssh.py b/tests/goth_tests/test_run_ssh.py index ca1d1ec7a..21e0cee6d 100644 --- a/tests/goth_tests/test_run_ssh.py +++ b/tests/goth_tests/test_run_ssh.py @@ -32,7 +32,6 @@ async def test_run_ssh( config_overrides: List[Override], ssh_verify_connection: bool, ) -> None: - if ssh_verify_connection: ssh_check = pexpect.spawn("/usr/bin/which ssh") exit_code = ssh_check.wait() @@ -60,7 +59,6 @@ async def test_run_ssh( ) async with runner(goth_config.containers): - requestor = runner.get_probes(probe_type=RequestorProbe)[0] async with requestor.run_command_on_host( diff --git a/tests/goth_tests/test_run_webapp.py b/tests/goth_tests/test_run_webapp.py index 722e674da..7235846df 100644 --- a/tests/goth_tests/test_run_webapp.py +++ b/tests/goth_tests/test_run_webapp.py @@ -55,7 +55,6 @@ async def test_run_webapp( ) async with runner(goth_config.containers): - requestor = runner.get_probes(probe_type=RequestorProbe)[0] async with requestor.run_command_on_host( diff --git a/tests/goth_tests/test_run_yacat.py b/tests/goth_tests/test_run_yacat.py index 7ae9055b2..922ad9877 100644 --- a/tests/goth_tests/test_run_yacat.py +++ b/tests/goth_tests/test_run_yacat.py @@ -13,8 +13,6 @@ from goth.runner.log import configure_logging from goth.runner.probe import RequestorProbe -from yapapi.log import SummaryLogger - from .assertions import assert_all_invoices_accepted, assert_no_errors, assert_tasks_processed logger = logging.getLogger("goth.test.run_yacat") @@ -46,7 +44,6 @@ async def test_run_yacat( goth_config_path: Path, config_overrides: List[Override], ) -> None: - configure_logging(log_dir) # This is the default configuration with 2 wasm/VM providers @@ -60,7 +57,6 @@ async def test_run_yacat( ) async with runner(goth_config.containers): - requestor = runner.get_probes(probe_type=RequestorProbe)[0] logfile = f"hashcat-yapapi-{datetime.now().strftime('%Y-%m-%d_%H.%M.%S')}.log" @@ -71,7 +67,6 @@ async def test_run_yacat( f"--log-file {(log_dir / logfile).resolve()}", env=os.environ, ) as (_cmd_task, cmd_monitor, _process_monitor): - # Add assertions to the command output monitor `cmd_monitor`: cmd_monitor.add_assertion(assert_no_errors) cmd_monitor.add_assertion(assert_all_invoices_accepted) @@ -95,7 +90,5 @@ async def test_run_yacat( await cmd_monitor.wait_for_pattern(".*Password found: yo", timeout=60) logger.info("Password found, waiting for Golem shutdown") - await cmd_monitor.wait_for_pattern( - f".*{SummaryLogger.GOLEM_SHUTDOWN_SUCCESSFUL_MESSAGE}", timeout=120 - ) + await cmd_monitor.wait_for_pattern(".*Golem engine has shut down", timeout=120) logger.info("Requestor script finished") diff --git a/tests/rest/test_allocation.py b/tests/rest/test_allocation.py index 0b217690a..3af987693 100644 --- a/tests/rest/test_allocation.py +++ b/tests/rest/test_allocation.py @@ -16,7 +16,6 @@ async def yapapi_payment(request): @pytest.mark.skipif("not config.getvalue('yaApiKey')") @pytest.mark.asyncio async def test_allocation(yapapi_payment: Payment): - async for a in yapapi_payment.allocations(): print("a=", a) diff --git a/tests/rest/test_repeat_on_error.py b/tests/rest/test_repeat_on_error.py index b1b7ba4eb..dbd460e40 100644 --- a/tests/rest/test_repeat_on_error.py +++ b/tests/rest/test_repeat_on_error.py @@ -42,7 +42,6 @@ ) @pytest.mark.asyncio async def test_repeat_on_error(max_tries, exceptions, calls_expected, expected_error): - calls_made = 0 @repeat_on_error(max_tries=max_tries, interval=0.0) @@ -67,7 +66,6 @@ async def request(): @pytest.mark.asyncio async def test_suppressed_exceptions(): - async with SuppressedExceptions(is_intermittent_error) as se: pass assert se.exception is None diff --git a/tests/services/test_service_runner.py b/tests/services/test_service_runner.py index e72ce1cf9..068aaf1ef 100644 --- a/tests/services/test_service_runner.py +++ b/tests/services/test_service_runner.py @@ -54,7 +54,6 @@ async def test_ensure_alive( with mock.patch( "yapapi.ctx.WorkContext.get_raw_state", mock.AsyncMock(side_effect=side_effect) ) as grs_mock: - service_runner = ServiceRunner( mock.Mock(), health_check_interval=0.001, diff --git a/tests/storage/test_gftp.py b/tests/storage/test_gftp.py index 36a031299..13bdb9deb 100644 --- a/tests/storage/test_gftp.py +++ b/tests/storage/test_gftp.py @@ -21,7 +21,6 @@ def test_dir(): the directory. """ with tempfile.TemporaryDirectory() as tmpdir: - try: test_files = set() dir_path = Path(tmpdir) @@ -96,7 +95,6 @@ async def close(self, *, urls: List[str]) -> List[gftp.CommandStatus]: @pytest.fixture(scope="function") def mock_service(monkeypatch): - service = MockService() monkeypatch.setattr(gftp, "service", lambda _debug: service) return service @@ -172,7 +170,6 @@ async def worker(id: int, provider: gftp.GftpProvider): monkeypatch.setenv(gftp.USE_GFTP_CLOSE_ENV_VAR, "1") async with gftp.GftpProvider(tmpdir=temp_dir) as provider: - assert isinstance(provider, gftp.GftpProvider) loop = asyncio.get_event_loop() workers = [loop.create_task(worker(n, provider)) for n in range(num_workers)] diff --git a/tests/strategy/test_default_strategies.py b/tests/strategy/test_default_strategies.py index 15d6fd6d2..662e43fbd 100644 --- a/tests/strategy/test_default_strategies.py +++ b/tests/strategy/test_default_strategies.py @@ -55,7 +55,6 @@ async def test_LeastExpensiveLinearPayuMS_price_caps(): triples = list(product(prices, repeat=3)) # get triples of (cpu_price, time_price, fixed_price) for cpu_price, time_price, fixed_price in triples: - offer = OfferProposalFactory(coeffs=(cpu_price, time_price, fixed_price)) async def _test_strategy(strategy, cpu_price_cap, time_price_cap, fixed_price_cap): diff --git a/tests/test_agreements_pool.py b/tests/test_agreements_pool.py index 1d752c441..69070853a 100644 --- a/tests/test_agreements_pool.py +++ b/tests/test_agreements_pool.py @@ -68,7 +68,6 @@ async def test_use_agreement_shuffles_proposals(): all_proposal_ids = range(5) for i in range(100): - # Prepare proposal data, all proposals have the same score except the one with id 0 proposals = [] for n in all_proposal_ids: diff --git a/yapapi/contrib/service/__init__.py b/yapapi/contrib/service/__init__.py index b6f656e82..2a9711cdc 100644 --- a/yapapi/contrib/service/__init__.py +++ b/yapapi/contrib/service/__init__.py @@ -1,4 +1,4 @@ from typing_extensions import Final -WEBSOCKET_CHUNK_LIMIT: Final[int] = 2 ** 16 +WEBSOCKET_CHUNK_LIMIT: Final[int] = 2**16 DEFAULT_TIMEOUT: Final[float] = 300.0 diff --git a/yapapi/contrib/service/http_proxy.py b/yapapi/contrib/service/http_proxy.py index 714936a2d..19fd40667 100644 --- a/yapapi/contrib/service/http_proxy.py +++ b/yapapi/contrib/service/http_proxy.py @@ -26,9 +26,9 @@ logger = logging.getLogger(__name__) -WEBSOCKET_CHUNK_LIMIT: Final[int] = 2 ** 16 +WEBSOCKET_CHUNK_LIMIT: Final[int] = 2**16 DEFAULT_TIMEOUT: Final[float] = 30.0 -DEFAULT_MAX_REQUEST_SIZE: Final[int] = 128 * 1024 ** 2 +DEFAULT_MAX_REQUEST_SIZE: Final[int] = 128 * 1024**2 class _ResponseParser: @@ -281,7 +281,7 @@ async def stop(self): class _Server(web.Server): """Override of aiohttp.web.Server to allow for an increase of the request size.""" - def __init__(self, *args, client_max_size=1024 ** 2, **kwargs): + def __init__(self, *args, client_max_size=1024**2, **kwargs): self._client_max_size = client_max_size super().__init__(*args, **kwargs) diff --git a/yapapi/engine.py b/yapapi/engine.py index 07f7ca6e1..66ac24c3a 100644 --- a/yapapi/engine.py +++ b/yapapi/engine.py @@ -308,7 +308,6 @@ async def _shutdown(self, *exc_info): # Wait for some time for invoices for unpaid agreements, # then cancel the invoices service if self._process_invoices_job: - unpaid_agreements = self._invoice_manager.payable_unpaid_agreement_ids if unpaid_agreements: logger.info( @@ -336,7 +335,6 @@ async def _shutdown(self, *exc_info): logger.debug("Got error when waiting for services to finish", exc_info=True) async def _create_allocations(self) -> rest.payment.MarketDecoration: - if not self._budget_allocations: async for account in self._payment_api.accounts(): driver = account.driver.lower() diff --git a/yapapi/executor/__init__.py b/yapapi/executor/__init__.py index d36f75323..e69d4f5c7 100644 --- a/yapapi/executor/__init__.py +++ b/yapapi/executor/__init__.py @@ -158,7 +158,6 @@ async def _submit( workers: Set[asyncio.Task], job: Job, ) -> AsyncGenerator[Task[D, R], None]: - done_queue: asyncio.Queue[Task[D, R]] = asyncio.Queue() def on_task_done(task: Task[D, R], status: TaskStatus) -> None: @@ -185,7 +184,6 @@ async def run_worker(work_context: WorkContext) -> None: with work_queue.new_consumer() as consumer: try: - # the `task_generator` here is passed as the `tasks` argument to the user's # `worker` function # @@ -278,7 +276,6 @@ async def worker_starter() -> None: try: while wait_until_done in services or not done_queue.empty(): - now = datetime.now(timezone.utc) if now > job.expiration_time: raise TimeoutError(f"Job timed out after {self._timeout}") @@ -324,7 +321,6 @@ async def worker_starter() -> None: raise finally: - await work_queue.close() # Importing this at the beginning would cause circular dependencies diff --git a/yapapi/executor/_smartq.py b/yapapi/executor/_smartq.py index 68fe0ab0d..d4613ed93 100644 --- a/yapapi/executor/_smartq.py +++ b/yapapi/executor/_smartq.py @@ -112,7 +112,6 @@ async def get(self, consumer: "Consumer[Item]") -> Handle[Item]: """Get a handle to the next item to be processed (either a new one or rescheduled).""" async with self._lock: while not self.finished(): - handle = self.__find_rescheduled_item(consumer) if handle: self._rescheduled_items.remove(handle) diff --git a/yapapi/log.py b/yapapi/log.py index ab94a7d20..4cc52ae5a 100644 --- a/yapapi/log.py +++ b/yapapi/log.py @@ -465,7 +465,6 @@ def _handle(self, event: events.Event): ) elif isinstance(event, events.AgreementConfirmed): - self.logger.info( "Agreement confirmed by provider '%s'", self.agreement_provider_info[event.agr_id].name, diff --git a/yapapi/rest/common.py b/yapapi/rest/common.py index 1a36a7cc2..4c58255b1 100644 --- a/yapapi/rest/common.py +++ b/yapapi/rest/common.py @@ -69,7 +69,6 @@ async def wrapper(*args, **kwargs): """Make at most `max_tries` attempts to call `func`.""" for try_num in range(1, max_tries + 1): - if try_num > 1: await asyncio.sleep(interval) diff --git a/yapapi/rest/market.py b/yapapi/rest/market.py index fed2db511..e70a646f1 100644 --- a/yapapi/rest/market.py +++ b/yapapi/rest/market.py @@ -231,7 +231,6 @@ async def delete(self): async def events(self) -> AsyncIterator[OfferProposal]: """Yield counter-proposals based on the incoming, matching Offers.""" while self._open: - proposals = [] try: async with SuppressedExceptions(is_intermittent_error): diff --git a/yapapi/rest/payment.py b/yapapi/rest/payment.py index ec55e484e..324655445 100644 --- a/yapapi/rest/payment.py +++ b/yapapi/rest/payment.py @@ -113,7 +113,6 @@ async def __aexit__(self, exc_type, exc_val, exc_tb): class Payment(object): - __slots__ = ("_api",) def __init__(self, api_client: ApiClient): @@ -206,7 +205,6 @@ async def debit_note(self, debit_note_id: str) -> DebitNote: return DebitNote(_api=self._api, _base=debit_note) async def invoices(self) -> AsyncIterator[Invoice]: - for invoice_obj in cast(Iterable[yap.Invoice], await self._api.get_invoices()): yield Invoice(_api=self._api, _base=invoice_obj) diff --git a/yapapi/storage/gftp.py b/yapapi/storage/gftp.py index 44b41a4e1..48f24ba18 100644 --- a/yapapi/storage/gftp.py +++ b/yapapi/storage/gftp.py @@ -369,13 +369,11 @@ async def upload_stream(self, length: int, stream: AsyncIterator[bytes]) -> Sour return await self.upload_file(file_name, _temporary=True) async def upload_file(self, path: os.PathLike, _temporary: bool = False) -> Source: - path = Path(path) _logger.debug("Publishing file %s...", path) process = await self.__get_process() async with self._lock: - links = await process.publish(files=[str(path)]) assert len(links) == 1, "Invalid gftp publish response" @@ -407,7 +405,6 @@ async def upload_file(self, path: os.PathLike, _temporary: bool = False) -> Sour return source async def release_source(self, source: Source) -> None: - if not isinstance(source, GftpSource): raise ValueError(f"Expected an instance of GftpSource, got {type(source)} instead") @@ -415,7 +412,6 @@ async def release_source(self, source: Source) -> None: _logger.debug("Releasing file %s with URL = %s ...", source.path, url) async with self._lock: - if url not in self._published_sources: raise ValueError( f"Trying to release an unpublished URL {url}, path = {source.path}" @@ -428,7 +424,6 @@ async def release_source(self, source: Source) -> None: ) if info.publish_count == 0: - _logger.debug("Unpublishing URL %s...", url) if self._close_urls: process = await self.__get_process() diff --git a/yapapi/strategy/base.py b/yapapi/strategy/base.py index e2073182c..56c7543b8 100644 --- a/yapapi/strategy/base.py +++ b/yapapi/strategy/base.py @@ -210,7 +210,6 @@ async def respond_to_provider_offer( if prop_value is not None and ( mid_agreement_payments_enabled or prop_key not in MID_AGREEMENT_PAYMENTS_PROPS ): - if prop_value not in acceptable_range: our_value = acceptable_range.clamp(prop_value) logger.debug( diff --git a/yapapi/strategy/least_expensive.py b/yapapi/strategy/least_expensive.py index e5ddfec8d..00906ad68 100644 --- a/yapapi/strategy/least_expensive.py +++ b/yapapi/strategy/least_expensive.py @@ -64,7 +64,6 @@ async def score_offer(self, offer: rest.market.OfferProposal) -> float: expected_usage = [] for resource in linear.usage_vector: - if linear.price_for[resource] > self._max_price_for[resource]: self._logger.debug( "Rejected offer %s: price for '%s' higher than price cap %f.",