fractal-task-tools 0.0.2__tar.gz → 0.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of fractal-task-tools might be problematic. Click here for more details.

Files changed (26) hide show
  1. {fractal_task_tools-0.0.2/src/fractal_task_tools.egg-info → fractal_task_tools-0.0.3}/PKG-INFO +1 -1
  2. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3}/pyproject.toml +2 -2
  3. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3}/src/fractal_task_tools/__init__.py +1 -1
  4. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3}/src/fractal_task_tools/_cli.py +2 -2
  5. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3}/src/fractal_task_tools/_create_manifest.py +33 -9
  6. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3}/src/fractal_task_tools/_signature_constraints.py +2 -3
  7. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3/src/fractal_task_tools.egg-info}/PKG-INFO +1 -1
  8. fractal_task_tools-0.0.3/tests/test_extract_function.py +43 -0
  9. fractal_task_tools-0.0.2/tests/test_extract_function.py +0 -26
  10. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3}/LICENSE +0 -0
  11. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3}/README.md +0 -0
  12. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3}/setup.cfg +0 -0
  13. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3}/src/fractal_task_tools/_args_schemas.py +0 -0
  14. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3}/src/fractal_task_tools/_descriptions.py +0 -0
  15. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3}/src/fractal_task_tools/_package_name_tools.py +0 -0
  16. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3}/src/fractal_task_tools/_pydantic_generatejsonschema.py +0 -0
  17. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3}/src/fractal_task_tools/_task_docs.py +0 -0
  18. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3}/src/fractal_task_tools/_titles.py +0 -0
  19. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3}/src/fractal_task_tools/task_models.py +0 -0
  20. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3}/src/fractal_task_tools.egg-info/SOURCES.txt +0 -0
  21. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3}/src/fractal_task_tools.egg-info/dependency_links.txt +0 -0
  22. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3}/src/fractal_task_tools.egg-info/entry_points.txt +0 -0
  23. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3}/src/fractal_task_tools.egg-info/requires.txt +0 -0
  24. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3}/src/fractal_task_tools.egg-info/top_level.txt +0 -0
  25. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3}/tests/test_create_schema_for_single_task.py +0 -0
  26. {fractal_task_tools-0.0.2 → fractal_task_tools-0.0.3}/tests/test_unit_lib_descriptions.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: fractal-task-tools
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Summary: Shared tools for Fractal tasks
5
5
  Author-email: Tommaso Comparin <tommaso.comparin@exact-lab.it>
6
6
  License: BSD-3-Clause
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fractal-task-tools"
3
- version = "0.0.2"
3
+ version = "0.0.3"
4
4
  description = "Shared tools for Fractal tasks"
5
5
  authors = [
6
6
  {name="Tommaso Comparin", email="tommaso.comparin@exact-lab.it"},
@@ -34,7 +34,7 @@ build-backend = "setuptools.build_meta"
34
34
  fractal-manifest = "fractal_task_tools._cli:main"
35
35
 
36
36
  [tool.bumpver]
37
- current_version = "0.0.2"
37
+ current_version = "0.0.3"
38
38
  version_pattern = "MAJOR.MINOR.PATCH[PYTAGNUM]"
39
39
  commit_message = "bump version {old_version} -> {new_version}"
40
40
  commit = true
@@ -2,4 +2,4 @@ import logging
2
2
 
3
3
  logging.basicConfig(level=logging.INFO)
4
4
 
5
- __VERSION__ = "0.0.2"
5
+ __VERSION__ = "0.0.3"
@@ -1,7 +1,7 @@
1
1
  import argparse as ap
2
2
  import sys
3
3
 
4
- from fractal_task_tools._create_manifest import check_manifest_unchanged
4
+ from fractal_task_tools._create_manifest import check_manifest
5
5
  from fractal_task_tools._create_manifest import create_manifest
6
6
  from fractal_task_tools._create_manifest import write_manifest_to_file
7
7
 
@@ -66,7 +66,7 @@ def main():
66
66
  raw_package_name=args.package,
67
67
  task_list_path=args.task_list_path,
68
68
  )
69
- check_manifest_unchanged(
69
+ check_manifest(
70
70
  raw_package_name=args.package,
71
71
  manifest=manifest,
72
72
  )
@@ -3,6 +3,8 @@ Generate JSON schemas for task arguments and combine them into a manifest.
3
3
  """
4
4
  import json
5
5
  import logging
6
+ import os
7
+ import sys
6
8
  from importlib import import_module
7
9
  from pathlib import Path
8
10
  from typing import Any
@@ -157,17 +159,26 @@ def write_manifest_to_file(
157
159
  raw_package_name:
158
160
  manifest: The manifest object
159
161
  """
162
+ logging.info("[write_manifest_to_file] START")
163
+
160
164
  package_name = normalize_package_name(raw_package_name)
165
+ logging.info(f"[write_manifest_to_file] {package_name=}")
166
+
161
167
  imported_package = import_module(package_name)
162
168
  package_root_dir = Path(imported_package.__file__).parent
163
- manifest_path = package_root_dir / MANIFEST_FILENAME
164
- with manifest_path.open("w") as f:
169
+ manifest_path = (package_root_dir / MANIFEST_FILENAME).as_posix()
170
+ logging.info(f"[write_manifest_to_file] {os.getcwd()=}")
171
+ logging.info(f"[write_manifest_to_file] {package_root_dir=}")
172
+ logging.info(f"[write_manifest_to_file] {manifest_path=}")
173
+
174
+ with open(manifest_path, "w") as f:
165
175
  json.dump(manifest, f, indent=2)
166
176
  f.write("\n")
167
- logging.info(f"Manifest stored in {manifest_path.as_posix()}")
177
+
178
+ logging.info("[write_manifest_to_file] END")
168
179
 
169
180
 
170
- def check_manifest_unchanged(
181
+ def check_manifest(
171
182
  *,
172
183
  raw_package_name: str,
173
184
  manifest: str,
@@ -179,12 +190,25 @@ def check_manifest_unchanged(
179
190
  raw_package_name:
180
191
  manifest: The manifest object
181
192
  """
193
+
182
194
  package_name = normalize_package_name(raw_package_name)
195
+ logging.info(f"[check_manifest] {package_name=}")
196
+
183
197
  imported_package = import_module(package_name)
184
198
  package_root_dir = Path(imported_package.__file__).parent
185
- manifest_path = package_root_dir / MANIFEST_FILENAME
186
- with manifest_path.open("f") as f:
199
+ manifest_path = (package_root_dir / MANIFEST_FILENAME).as_posix()
200
+ logging.info(f"[check_manifest] {os.getcwd()=}")
201
+ logging.info(f"[check_manifest] {package_root_dir=}")
202
+ logging.info(f"[check_manifest] {manifest_path=}")
203
+
204
+ with open(manifest_path, "r") as f:
187
205
  old_manifest = json.load(f)
188
- logging.info(f"Manifest read from {manifest_path.as_posix()}")
189
- if manifest != old_manifest:
190
- raise ValueError("New/old manifests differ")
206
+ if manifest == old_manifest:
207
+ logging.info("[check_manifest] On-disk manifest is up to date.")
208
+ else:
209
+ logging.error("[check_manifest] On-disk manifest is not up to date.")
210
+ print(json.dumps(old_manifest, indent=2))
211
+ print(json.dumps(manifest, indent=2))
212
+ sys.exit("New/old manifests differ")
213
+
214
+ logging.info("[check_manifest] END")
@@ -3,7 +3,6 @@ import logging
3
3
  from importlib import import_module
4
4
  from inspect import signature
5
5
  from pathlib import Path
6
- from typing import Callable
7
6
 
8
7
  from pydantic.v1.decorator import ALT_V_ARGS
9
8
  from pydantic.v1.decorator import ALT_V_KWARGS
@@ -25,7 +24,7 @@ def _extract_function(
25
24
  function_name: str,
26
25
  package_name: str,
27
26
  verbose: bool = False,
28
- ) -> Callable:
27
+ ) -> callable:
29
28
  """
30
29
  Extract function from a module with the same name.
31
30
 
@@ -58,7 +57,7 @@ def _extract_function(
58
57
  return task_function
59
58
 
60
59
 
61
- def _validate_function_signature(function: Callable):
60
+ def _validate_function_signature(function: callable):
62
61
  """
63
62
  Validate the function signature.
64
63
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: fractal-task-tools
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Summary: Shared tools for Fractal tasks
5
5
  Author-email: Tommaso Comparin <tommaso.comparin@exact-lab.it>
6
6
  License: BSD-3-Clause
@@ -0,0 +1,43 @@
1
+ import pytest
2
+ from fractal_task_tools._signature_constraints import _extract_function
3
+
4
+
5
+ def test_extract_function():
6
+ for verbose in (True, False):
7
+ function = _extract_function(
8
+ module_relative_path="_create_manifest.py",
9
+ package_name="fractal_task_tools",
10
+ function_name="create_manifest",
11
+ verbose=verbose,
12
+ )
13
+ assert function.__name__ == "create_manifest"
14
+
15
+ with pytest.raises(
16
+ ValueError,
17
+ match="must end with '.py'",
18
+ ):
19
+ _extract_function(
20
+ module_relative_path="_create_manifest",
21
+ package_name="fractal_task_tools",
22
+ function_name="missing_function",
23
+ verbose=True,
24
+ )
25
+ with pytest.raises(
26
+ AttributeError,
27
+ match="has no attribute 'missing_function'",
28
+ ):
29
+ _extract_function(
30
+ module_relative_path="_create_manifest.py",
31
+ package_name="fractal_task_tools",
32
+ function_name="missing_function",
33
+ )
34
+
35
+ with pytest.raises(
36
+ ModuleNotFoundError,
37
+ match="No module named 'fractal_task_tools.missing_module'",
38
+ ):
39
+ _extract_function(
40
+ module_relative_path="missing_module.py",
41
+ package_name="fractal_task_tools",
42
+ function_name="missing_function",
43
+ )
@@ -1,26 +0,0 @@
1
- import pytest
2
- from devtools import debug
3
- from fractal_task_tools._signature_constraints import _extract_function
4
-
5
-
6
- @pytest.mark.xfail(reason="FIXME: depends on fractal-tasks-core")
7
- def test_extract_function():
8
- """
9
- This test showcases the use of `_extract_function`.
10
- """
11
-
12
- fun1 = _extract_function(
13
- module_relative_path="zarr_utils.py",
14
- package_name="fractal_tasks_core.ngff",
15
- function_name="load_NgffImageMeta",
16
- verbose=True,
17
- )
18
- debug(fun1)
19
-
20
- fun2 = _extract_function(
21
- module_relative_path="ngff.zarr_utils.py",
22
- package_name="fractal_tasks_core",
23
- function_name="load_NgffImageMeta",
24
- verbose=True,
25
- )
26
- debug(fun2)