Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 3 additions & 2 deletions utilix/batchq.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ def get_server_type():
# for non-dali hosts, SCRATCH_DIR must have write permission
if not os.access(SCRATCH_DIR, os.W_OK) and SERVER != "Dali":
raise ValueError(
f"SCRATCH_DIR {SCRATCH_DIR} does not have write permission. "
"You may need to set SCRATCH_DIR manually in your .bashrc or .bash_profile."
f"SCRATCH {SCRATCH_DIR} does not have write permission. "
"You may need to set SCRATCH manually in your .bashrc or .bash_profile using"
"export SCRATCH=/path/to/your/scratch"
)

PARTITIONS: List[str] = [
Expand Down
15 changes: 5 additions & 10 deletions utilix/mongo_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def __init__(
(only deactivate if you are using a brand new database)!

"""

if collection is None:
if not readonly:
# We want admin access to start writing data!
Expand Down Expand Up @@ -169,14 +168,11 @@ def config_exists(self, config):
return self.collection.count_documents(query) > 0

def md5_stored(self, abs_path):
"""
NB: RAM intensive operation!
Carefully compare if the MD5 identifier is the same as the file
as stored under abs_path.
"""NB: RAM intensive operation! Carefully compare if the MD5 identifier is the same as the
file as stored under abs_path.

:param abs_path: str, absolute path to the file name
:return: bool, returns if the exact same file is already stored
in the database
:return: bool, returns if the exact same file is already stored in the database

"""
if not os.path.exists(abs_path):
Expand Down Expand Up @@ -205,12 +201,11 @@ def list_files(self):

@staticmethod
def compute_md5(abs_path):
"""
NB: RAM intensive operation!
Get the md5 hash of a file stored under abs_path
"""NB: RAM intensive operation! Get the md5 hash of a file stored under abs_path.

:param abs_path: str, absolute path to a file
:return: str, the md5-hash of the requested file

"""
# This function is copied from:
# stackoverflow.com/questions/3431825/generating-an-md5-checksum-of-a-file
Expand Down
5 changes: 0 additions & 5 deletions utilix/rundb.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ def get_doc(self, identifier):
takes place automatically.

"""

# map from all kinds of types (int, np int, ...)
identifier = str(identifier)

Expand All @@ -290,7 +289,6 @@ def get_data(self, identifier, **filters):
automatically.

"""

# map from all kinds of types (int, np int, ...)
identifier = str(identifier)

Expand Down Expand Up @@ -321,7 +319,6 @@ def update_data(self, identifier, datum):
Identifier can be run number of name.

"""

datum = cleanup_datadict(datum)

# map from all kinds of types (int, np int, ...)
Expand All @@ -337,7 +334,6 @@ def update_data(self, identifier, datum):

def delete_data(self, identifier, datum):
"""Updates a datum for a document with a matching identifier (name or run number)"""

# map from all kinds of types (int, np int, ...)
identifier = str(identifier)

Expand Down Expand Up @@ -519,7 +515,6 @@ def get_file_md5(self, filename):

class PyMongoCannotConnect(Exception):
"""Raise error when we cannot connect to the pymongo client."""

pass


Expand Down
8 changes: 2 additions & 6 deletions utilix/scripts/xefind.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def get_runs_from_source(science_run, source):
list: A list of run numbers matching the given science run and source.

"""

query = SCIENCE_RUNS[science_run]
query["source"] = source
# end is lt now in GMT time
Expand Down Expand Up @@ -153,7 +152,6 @@ def get_lineage_hash_from_version(context, versions, data_type):
str or None: The lineae hash if found, None otherwise.

"""

ctxs = xent_collection(collection="contexts")

if context == "xenonnt_online":
Expand Down Expand Up @@ -229,7 +227,6 @@ def check_runs_available(data_type, run_ids, extra_location="", livetime=False):
pandas.DataFrame: A DataFrame containing the availability information for each run ID.

"""

if not run_ids:
raise ValueError("No run_ids found")

Expand Down Expand Up @@ -300,7 +297,6 @@ def get_runs_from_db(run_ids, data_type, lineage_hash, location=None):
list: A list of run IDs matching the criteria.

"""

coll = xent_collection(collection="runs")
run_ids = [int(run_id) for run_id in run_ids]

Expand All @@ -323,9 +319,9 @@ def parse_args():
argparse.Namespace: The parsed command line arguments.

"""

parser = argparse.ArgumentParser(
description="""
description=\
"""
Check if the data is available for a given list of runs,
or for a given source and science run.
You can provide a file with the run_ids,
Expand Down
2 changes: 0 additions & 2 deletions utilix/tarball.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

def filter_tarinfo(tarinfo, git_ignored_files, tarball_ignore_patterns=None):
"""Custom filter for tarfile to exclude Git-ignored files and .tarballignore patterns."""

# Exclude Git-ignored files
if any(f in tarinfo.name for f in git_ignored_files):
return None
Expand Down Expand Up @@ -47,7 +46,6 @@ def tarball_path(self):

def create_tarball(self, overwrite=False):
"""Create the tarball of package."""

if os.path.exists(self.tarball_path) and not overwrite:
raise RuntimeError(f"{self.tarball_path} already exists!")

Expand Down