Skip to content

Commit c9cec31

Browse files
author
Zhaozhong Shi
committed
New Updated for SQLite Local Copying for 10% Production
1 parent 89c831d commit c9cec31

File tree

3 files changed

+70
-1
lines changed

3 files changed

+70
-1
lines changed

python/hpsmc/component.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ def __init__(self,
6666
self.logger = logging.getLogger("{}.{}".format(__name__, self.__class__.__name__))
6767

6868
def cmd_line_str(self):
69-
cl = [self.command]
69+
cl = []
70+
if self.command:
71+
cl.append(self.command)
7072
cl.extend(self.cmd_args())
7173
return ' '.join(cl)
7274

python/hpsmc/tools.py

+51
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,57 @@ def execute(self, log_out, log_err):
157157
return proc.returncode
158158

159159

160+
161+
class SQLiteProc(Component):
162+
"""!
163+
Copy the SQLite database file to the desired location.
164+
"""
165+
166+
def __init__(self, **kwargs):
167+
"""!
168+
Initialize SQLiteProc to copy the SQLite file.
169+
"""
170+
171+
self.source_file = '/w/hallb-scshelf2102/hps/zshi/swiftjob/SQLite/LocalTest/hps_conditions_2025_03_06.sqlite'
172+
self.destination_file = './hps_conditions_2025_03_06.sqlite' # Modify this as needed
173+
174+
175+
# Ensure to call the parent constructor properly
176+
Component.__init__(self, name='sqlite_file_copy', **kwargs)
177+
178+
179+
def cmd_args(self):
180+
"""!
181+
Return dummy command arguments to satisfy the parent class.
182+
"""
183+
cmd_args = ["(no-command-needed)"]
184+
185+
if not all(isinstance(arg, str) for arg in cmd_args):
186+
raise ValueError("All arguments must be strings.")
187+
# return ["(no-command-needed)"]
188+
return ['--source', self.source_file, '--destination', self.destination_file]
189+
190+
def execute(self, log_out, log_err):
191+
"""!
192+
Execute the file copy operation.
193+
"""
194+
195+
try:
196+
# Copy the file
197+
198+
self.logger.info(f"Copying file from {self.source_file} to {self.destination_file}")
199+
shutil.copy(self.source_file, self.destination_file)
200+
201+
# Log success
202+
self.logger.info(f"Successfully copied file to {self.destination_file}")
203+
204+
return 0 # Success code
205+
206+
except Exception as e:
207+
self.logger.error(f"Error during file copy: {e}")
208+
return 1 # Error code
209+
210+
160211
class JobManager(Component):
161212
"""!
162213
Run the hps-java JobManager class.
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""!
2+
@file data_cnv_job.py
3+
4+
Convert EVIO to LCIO and then process with HPSTR to produce a recon tuple.
5+
"""
6+
from hpsmc.tools import EvioToLcio, HPSTR, SQLiteProc
7+
8+
job.description = 'EVIO converter'
9+
10+
sqlite = SQLiteProc()
11+
12+
cnv = EvioToLcio(steering='recon')
13+
14+
tuple = HPSTR(run_mode=1, cfg='recon')
15+
16+
job.add([sqlite, cnv, tuple])

0 commit comments

Comments
 (0)