Skip to content

Commit bb418d7

Browse files
committed
Simplify
1 parent f312873 commit bb418d7

File tree

2 files changed

+8
-69
lines changed

2 files changed

+8
-69
lines changed

fractal_tasks_core/dev/lib_signature_constraints.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,17 @@ def _extract_function(
5151
Path(module_relative_path).with_suffix("")
5252
)
5353
module_relative_path_dots = module_relative_path_no_py.replace("/", ".")
54-
if verbose:
55-
logging.info(
56-
f"Now calling `import_module` for "
57-
f"{package_name}.{module_relative_path_dots}"
58-
)
54+
logging.warning(
55+
f"Now calling `import_module` for "
56+
f"{package_name}.{module_relative_path_dots}"
57+
)
5958
imported_module = import_module(
6059
f"{package_name}.{module_relative_path_dots}"
6160
)
62-
if verbose:
63-
logging.info(
64-
f"Now getting attribute {function_name} from "
65-
f"imported module {imported_module}."
66-
)
61+
logging.warning(
62+
f"Now getting attribute {function_name} from "
63+
f"imported module {imported_module}."
64+
)
6765
task_function = getattr(imported_module, function_name)
6866
return task_function
6967

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import json
22

3-
import pytest
43
from devtools import debug
5-
from pydantic import validate_call
64

75
from fractal_tasks_core.dev.lib_args_schemas import (
86
create_schema_for_single_task,
@@ -21,60 +19,3 @@ def test_create_schema_for_single_task_usage_1():
2119
)
2220
debug(schema)
2321
print(json.dumps(schema, indent=2))
24-
25-
26-
@validate_call
27-
def task_function(arg_1: int = 1):
28-
"""
29-
Description
30-
31-
Args:
32-
arg_1: Description of arg_1.
33-
"""
34-
35-
36-
def test_create_schema_for_single_task_usage_2():
37-
"""
38-
This test reproduces the schema-creation scenario starting from an
39-
existing function, as it's done in tests.
40-
"""
41-
schema = create_schema_for_single_task(
42-
task_function=task_function,
43-
executable=__file__,
44-
package=None,
45-
verbose=True,
46-
)
47-
debug(schema)
48-
print(json.dumps(schema, indent=2))
49-
50-
51-
def test_create_schema_for_single_task_failures():
52-
"""
53-
This test reproduces some invalid usage of the schema-creation function
54-
"""
55-
with pytest.raises(ValueError):
56-
create_schema_for_single_task(
57-
task_function=task_function,
58-
executable=__file__,
59-
package="something",
60-
verbose=True,
61-
)
62-
with pytest.raises(ValueError):
63-
create_schema_for_single_task(
64-
task_function=task_function,
65-
executable="non_absolute/path/module.py",
66-
package=None,
67-
verbose=True,
68-
)
69-
with pytest.raises(ValueError):
70-
create_schema_for_single_task(
71-
executable="/absolute/path/cellpose_segmentation.py",
72-
package="fractal_tasks_core",
73-
verbose=True,
74-
)
75-
with pytest.raises(ValueError):
76-
create_schema_for_single_task(
77-
executable="cellpose_segmentation.py",
78-
package=None,
79-
verbose=True,
80-
)

0 commit comments

Comments
 (0)