Skip to content

Commit aae3734

Browse files
committed
Merge branch 'main' into doc
2 parents 3dfe461 + 6dce1b0 commit aae3734

5 files changed

Lines changed: 53 additions & 61 deletions

File tree

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,16 @@ class GenericDataWorkflow(WorkFlow):
109109
110110
# Initialize the pipeline run configuration
111111
def new(self, args: Dict[str, Any]):
112-
self.data_source = self.load_component(**args['data_source'])
113-
self.algorithm = self.load_component(**args['algorithm'])
114-
self.paths = ['results'] # Define artifact paths
112+
# Ensure all required configuration keys are provided
113+
if not self.template.issubset(set(args.keys())):
114+
raise ValueError(f'the args should have {", ".join(self.template- set(list(args.keys())))}')
115+
116+
115117
116118
# Perform setup (e.g., loading large datasets/models into memory)
117119
def prepare(self):
120+
self.data_source = self.load_component(**args['data_source'])
121+
self.algorithm = self.load_component(**args['algorithm'])
118122
print("Preparing workflow: loading external data or setting up environment...")
119123
return True
120124

src/plf/_pipeline.py

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -426,59 +426,3 @@ def status(self):
426426
return self.workflow.status()
427427
except:
428428
traceback.print_exc()
429-
430-
431-
432-
433-
434-
435-
436-
437-
438-
439-
440-
441-
442-
443-
444-
445-
446-
447-
448-
449-
450-
451-
452-
453-
454-
455-
456-
457-
458-
459-
460-
461-
462-
463-
464-
465-
466-
467-
468-
469-
470-
471-
472-
473-
474-
475-
476-
477-
478-
479-
480-
481-
482-
483-
484-

src/plf/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.2.1.2"
1+
__version__ = "0.2.1.3"

src/plf/danger.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from .utils import Db
2+
from .experiment import get_ppls, PipeLine
3+
4+
def corrupt_ppl(pplid: str):
5+
"""
6+
Deletes a record from the 'ppls' table in the SQLite database if the provided
7+
`pplid` exists and the user confirms the deletion.
8+
9+
Args:
10+
pplid (str): The ID of the person or record to be deleted.
11+
12+
Raises:
13+
FileNotFoundError: If the database directory doesn't exist.
14+
sqlite3.Error: If there is an issue executing the SQL query.
15+
16+
This function will:
17+
- Check if the provided `pplid` exists in the database.
18+
- Ask the user to confirm the deletion by entering the same `pplid`.
19+
- If the `pplid` matches, the record is deleted from the database.
20+
- If the `pplid` does not match, the deletion is aborted.
21+
- If the `pplid` is not found in the list, a message is displayed.
22+
"""
23+
P = PipeLine()
24+
db_path = f"{P.settings['data_path']}/ppls.db"
25+
# Use the Db class context manager for automatic connection management
26+
with Db(db_path=db_path) as db:
27+
# Ensure the pplid exists in the database before attempting deletion
28+
if pplid in get_ppls():
29+
print('Cross verify before deleting.')
30+
31+
# Single attempt to verify the correct pplid
32+
pplid1 = input("Enter the same pplid: ")
33+
if pplid == pplid1:
34+
try:
35+
# Perform the deletion (no need for db.commit() since execute handles it)
36+
db.execute("DELETE FROM ppls WHERE pplid = ?", (pplid,))
37+
print(f"Record with pplid {pplid} has been corupted.")
38+
except Exception as e:
39+
# In case there's an error, print the error message
40+
print(f"Error deleting record: {e}")
41+
else:
42+
print("pplid does not match. Deletion aborted.")
43+
else:
44+
print(f"pplid {pplid} not found in the list of available pplids.")

src/plf/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def status(self) -> str:
275275
Return the current status or progress of the workflow.
276276
"""
277277
return {}
278-
278+
279279
class Db:
280280
"""
281281
Lightweight SQLite wrapper with foreign key enforcement.

0 commit comments

Comments
 (0)