Skip to content

Commit

Permalink
Fix for Ryan upload_2
Browse files Browse the repository at this point in the history
  • Loading branch information
ConorFWild committed Dec 11, 2024
1 parent 16d1f80 commit 1a6dd96
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
18 changes: 7 additions & 11 deletions scripts/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,24 @@
def main():
parser = argparse.ArgumentParser(description="aligner")

parser.add_argument("-d", "--version-dir", required=True, help="Path to version dir")
parser.add_argument(
"-m", "--metadata_file", default=Constants.METADATA_XTAL_FILENAME.format(""), help="Metadata YAML file"
)
parser.add_argument("-a", "--assemblies", help="Assemblies YAML file")
parser.add_argument("-d", "--dir", help="Working directory")

parser.add_argument("-l", "--log-file", help="File to write logs to")
parser.add_argument("--log-level", type=int, default=0, help="Logging level")
parser.add_argument("--validate", action="store_true", help="Only perform validation")

args = parser.parse_args()

if args.log_file:
log = args.log_file
if args.dir:
log = str(Path(args.dir) / 'aligner.log')
else:
log = str(Path(args.version_dir).parent / 'aligner.log')
print("Using {} for log file".format(str(log)))
log = 'aligner.log'

logger = utils.Logger(logfile=log, level=args.log_level)
logger.info("aligner: ", args)
logger.info("Using {} for log file".format(str(log)))
utils.LOG = logger

a = Aligner(args.version_dir, args.metadata_file, args.assemblies, logger=logger)
a = Aligner(args.dir, logger=logger)
num_errors, num_warnings = a.validate()

if not args.validate:
Expand Down
25 changes: 22 additions & 3 deletions scripts/collate.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,42 @@
import argparse
import shutil
from pathlib import Path

from xchemalign import utils
from xchemalign.collator import Collator
from xchemalign import setup
from xchemalign.collator import Collator, _check_working_dir


def main():
parser = argparse.ArgumentParser(description="collator")

parser.add_argument("-c", "--config-file", default="config.yaml", help="Configuration file")
parser.add_argument("-d", "--dir", help="Working directory")
parser.add_argument("-l", "--log-file", help="File to write logs to")
parser.add_argument("--log-level", type=int, default=0, help="Logging level")
parser.add_argument("-v", "--validate", action="store_true", help="Only perform validation")
parser.add_argument("--no-git-info", action="store_false", help="Don't add GIT info to metadata")

args = parser.parse_args()

c = Collator(args.config_file, log_file=args.log_file, log_level=args.log_level)
if args.dir:
working_dir = Path(args.dir)
else:
working_dir = Path.cwd()

if _check_working_dir(working_dir):
print("Working dir does not seem to have been initialised - missing 'upload_current' symlink")
inp = input("Do you want the working dir to be initialised? (Y/N)")
if inp == "Y" or inp == "y":
print("Initialising working dir")
s = setup.Setup(args.dir)
s.run()
exit(1)

c = Collator(working_dir, log_file=args.log_file, log_level=args.log_level, include_git_info=args.no_git_info)

logger = c.logger
logger.info("collator: ", str(args))
utils.LOG = logger

meta = c.validate()

Expand Down

0 comments on commit 1a6dd96

Please sign in to comment.