Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Updated for SQLite Local Copying for 10% Production #429

Merged
merged 2 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion python/hpsmc/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ def __init__(self,
self.logger = logging.getLogger("{}.{}".format(__name__, self.__class__.__name__))

def cmd_line_str(self):
cl = [self.command]
cl = []
if self.command:
cl.append(self.command)
cl.extend(self.cmd_args())
return ' '.join(cl)

Expand Down
51 changes: 51 additions & 0 deletions python/hpsmc/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,57 @@ def execute(self, log_out, log_err):
return proc.returncode



class SQLiteProc(Component):
"""!
Copy the SQLite database file to the desired location.
"""

def __init__(self, **kwargs):
"""!
Initialize SQLiteProc to copy the SQLite file.
"""

self.source_file = '/w/hallb-scshelf2102/hps/zshi/swiftjob/SQLite/LocalTest/hps_conditions_2025_03_06.sqlite'
self.destination_file = './hps_conditions_2025_03_06.sqlite' # Modify this as needed


# Ensure to call the parent constructor properly
Component.__init__(self, name='sqlite_file_copy', **kwargs)


def cmd_args(self):
"""!
Return dummy command arguments to satisfy the parent class.
"""
cmd_args = ["(no-command-needed)"]

if not all(isinstance(arg, str) for arg in cmd_args):
raise ValueError("All arguments must be strings.")
# return ["(no-command-needed)"]
return ['--source', self.source_file, '--destination', self.destination_file]

def execute(self, log_out, log_err):
"""!
Execute the file copy operation.
"""

try:
# Copy the file

self.logger.info(f"Copying file from {self.source_file} to {self.destination_file}")
shutil.copy(self.source_file, self.destination_file)

# Log success
self.logger.info(f"Successfully copied file to {self.destination_file}")

return 0 # Success code

except Exception as e:
self.logger.error(f"Error during file copy: {e}")
return 1 # Error code


class JobManager(Component):
"""!
Run the hps-java JobManager class.
Expand Down
16 changes: 16 additions & 0 deletions python/jobs/data_cnv_10_percent_job.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""!
@file data_cnv_job.py
Convert EVIO to LCIO and then process with HPSTR to produce a recon tuple.
"""
from hpsmc.tools import EvioToLcio, HPSTR, SQLiteProc

job.description = 'EVIO converter'

sqlite = SQLiteProc()

cnv = EvioToLcio(steering='recon')

tuple = HPSTR(run_mode=1, cfg='recon')

job.add([sqlite, cnv, tuple])