Skip to content

Commit f342e8b

Browse files
authored
Merge pull request #46 from ttngu207/main
2 parents 4f37a78 + 75a486c commit f342e8b

File tree

6 files changed

+111
-54
lines changed

6 files changed

+111
-54
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Changelog
2+
3+
Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention.
4+
5+
## [0.5.0] - 2024-11-08
6+
7+
### Added
8+
9+
- Started CHANGELOG
10+
- Install with `pyproject.toml`
11+
12+
13+
[0.0.0]: https://github.com/datajoint-company/datajoint-utilities/releases/tag/0.5.0

datajoint_utilities/dj_worker/worker_schema.py

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,33 @@ class Process(dj.Part):
3838
"""
3939

4040
@classmethod
41-
def get_workers_progress(cls):
41+
def get_workers_progress(cls, worker_name=None, process_name=None):
4242
"""
4343
Return the operation progress for all registered workers (jobs status for each AutoPopulate process)
44-
:return: pandas DataFrame of workers jobs status
44+
45+
Args:
46+
worker_name (str): name of the worker (optionally restrict by worker_name)
47+
process_name (str): name of the process (optionally restrict by process_name)
48+
49+
Returns:
50+
pandas DataFrame of workers jobs status
4551
"""
52+
restriction = {}
53+
if worker_name:
54+
restriction["worker_name"] = worker_name
55+
if process_name:
56+
restriction["process"] = process_name
57+
4658
workflow_status = (
47-
(cls.Process & "key_source_sql is not NULL")
48-
.proj(
49-
"process",
50-
"key_source_sql",
51-
table_name="full_table_name",
52-
total="NULL",
53-
incomplete="NULL",
59+
(
60+
(cls.Process & "key_source_sql is not NULL").proj(
61+
"process",
62+
"key_source_sql",
63+
table_name="full_table_name",
64+
total="NULL",
65+
incomplete="NULL",
66+
)
67+
& restriction
5468
)
5569
.fetch(format="frame")
5670
.reset_index()
@@ -96,7 +110,7 @@ def get_workers_progress(cls):
96110
(
97111
workflow_status.loc[r_idx, "total"],
98112
workflow_status.loc[r_idx, "incomplete"],
99-
) = cls._get_key_source_count(r.key_source_sql, r.table_name)
113+
) = cls.get_key_source_count(r.key_source_sql, r.table_name)
100114

101115
# merge key_source and jobs status
102116
workflow_status.set_index("table_name", inplace=True)
@@ -124,7 +138,10 @@ def get_workers_progress(cls):
124138
return workflow_status
125139

126140
@classmethod
127-
def _get_key_source_count(cls, key_source_sql, target_full_table_name):
141+
def get_incomplete_key_source_sql(cls, key_source_sql, target_full_table_name):
142+
"""
143+
From `key_source_sql`, build a SQL statement to find incomplete key_source entries in the target table
144+
"""
128145
def _rename_attributes(table, props):
129146
return (
130147
table.proj(
@@ -169,6 +186,14 @@ def _remove_enclosed_parentheses(input_string):
169186
key_source_sql
170187
+ f"{AND_or_WHERE}(({ks_attrs_sql}) not in (SELECT {ks_attrs_sql} FROM {target.full_table_name}))"
171188
)
189+
return incomplete_sql
190+
191+
@classmethod
192+
def get_key_source_count(cls, key_source_sql, target_full_table_name):
193+
"""
194+
From `key_source_sql`, count the total and incomplete key_source entries in the target table
195+
"""
196+
incomplete_sql = cls.get_incomplete_key_source_sql(key_source_sql, target_full_table_name)
172197
try:
173198
total = len(dj.conn().query(key_source_sql).fetchall())
174199
incomplete = len(dj.conn().query(incomplete_sql).fetchall())

datajoint_utilities/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Package metadata."""
22

3-
__version__ = "0.4.0"
3+
__version__ = "0.5.0"

pyproject.toml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
[build-system]
2+
requires = ["setuptools>=62.0", "wheel>=0.37"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "datajoint-utilities"
7+
version = "0.5.0"
8+
description = "A general purpose repository containing all generic tools/utilities surrounding the DataJoint ecosystem"
9+
requires-python = ">=3.9, <3.12"
10+
license = { file = "LICENSE" }
11+
authors = [{ name = "DataJoint", email = "[email protected]" }]
12+
keywords = ["datajoint", "workflow"]
13+
classifiers = [
14+
"Operating System :: OS Independent",
15+
"Topic :: Software Development :: Libraries :: Python Modules",
16+
"License :: OSI Approved :: MIT License",
17+
"Programming Language :: Python :: 3",
18+
]
19+
dependencies = [
20+
"datajoint>=0.14.3",
21+
"termcolor",
22+
"slack-sdk",
23+
"python-dotenv",
24+
"boto3",
25+
"requests",
26+
]
27+
28+
[project.scripts]
29+
tmplcfg = "datajoint_utilities.cmdline.tmplcfg:cli"
30+
31+
[project.urls]
32+
Source = "https://github.com/datajoint-company/datajoint-utilities"
33+
DataJoint = "https://datajoint.com/docs"
34+
35+
[tool.setuptools]
36+
package-data = { "*" = ["*.pyi", "py.typed"] }
37+
38+
[tool.pytest.ini_options]
39+
minversion = "6.0"
40+
addopts = "-rA"
41+
testpaths = ["tests"]
42+
43+
[tool.black]
44+
line-length = 88
45+
target-version = ["py310"]
46+
color = false
47+
exclude = '''
48+
/(
49+
\.git
50+
| \.venv
51+
| _build
52+
| example_data
53+
| build
54+
| dist
55+
| env
56+
| venv
57+
)/
58+
'''
59+
60+
[tool.isort]
61+
profile = "black"

requirements.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)