Skip to content

Commit b7d4bc4

Browse files
committed
overwrite merging in branch, keeping changes to scripts, spec and tests
1 parent 2b31b48 commit b7d4bc4

File tree

11 files changed

+224
-68
lines changed

11 files changed

+224
-68
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.DS_Store
12
venv
23
.idea
3-
.DS_Store
4+
.DS_Store
5+
*.pyc

records/new_images/common_fields_spec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ dbxrefs:
8989
description: >
9090
Cross references for image/depicted entity in other databases taking the form db:accession where db
9191
is the short_form of a Site node in VFB and accession is an identifier in a third party database.
92-
uniq: True
92+
uniq: False
9393
type: String
9494
multiple: True
9595
pattern_arg: dbxref_strings

records/new_images/split_spec.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,9 @@ DBD:
3636
uniq: False
3737
flybase_feature: true
3838
multiple: False
39+
40+
is_a:
41+
compulsory: False
42+
uniq: False
43+
multiple: True
44+

records/new_metadata/newmeta_spec.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,3 @@ weight_per_roi:
121121

122122

123123

124-
125-
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Dummy relations spec file to hack split addition

records/new_splits/split_spec.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
AD_id:
2+
compulsory: False
3+
description: >
4+
The FBid of the feature corresponding to the activiation domain half of the split in FlyBase.
5+
Please use transposon rather than insertion ID.
6+
uniq: False
7+
type: Feature
8+
multiple: False
9+
10+
AD:
11+
compulsory: True
12+
description: >
13+
The name of the feature corresponding to the activiation domain half of the split in FlyBase.
14+
Please use transposon rather than insertion.
15+
uniq: False
16+
type: Feature
17+
multiple: False
18+
flybase_feature: true
19+
20+
21+
DBD_id:
22+
compulsory: False
23+
description: >
24+
The FBid of the feature corresponding to the DNA binding domain half of the split in FlyBase.
25+
Please use transposon rather than insertion ID.
26+
uniq: False
27+
type: Feature
28+
multiple: False
29+
30+
DBD:
31+
compulsory: True
32+
description: >
33+
The name of the feature corresponding to the DNA binding domain half
34+
of the split in FlyBase. Please use transposon rather than insertion.
35+
uniq: False
36+
flybase_feature: true
37+
multiple: False
38+
39+
synonyms:
40+
compulsory: False
41+
description: One or more additional names used to refer to the entity.
42+
uniq: False
43+
type: String
44+
multiple: True
45+
pattern_arg: anatomy_attributes
46+
pattern_dict_key: synonyms
47+
48+
dbxrefs:
49+
compulsory: False
50+
description: >
51+
Cross references for image/depicted entity in other databases taking the form db:accession where db
52+
is the short_form of a Site node in VFB and accession is an identifier in a third party database.
53+
uniq: True
54+
type: String
55+
multiple: True
56+
pattern_arg: dbxref_strings

records/relations_spec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ part_of:
1313
type: objectProperty
1414
restriction:
1515
field: short_form
16-
regex: "(FBbt|VFB)_.+"
16+
regex: "(FBbt|VFB|VFBexp)_.+"
1717
labels: ['Class']
1818

1919
expresses:

src/run_peevish.py

Lines changed: 89 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env python3
22

3+
import logging
34
from vfb.curation.peevish import get_recs
45
from vfb.curation.curation_loader import load_recs
5-
#from vfb.curation.cur_load import NewMetaDataWriter, NewImageWriter
66
import argparse
77
import warnings
88
import os
@@ -13,60 +13,104 @@
1313
2. Test load records in 'to_submit/'.
1414
"""
1515
# What logic, if any should live here?
16-
1716
## Should it know about the gross type of records and direct to the appropriate loading method, where gross currently = new_dataSet vs new_metadata, vs new image. Shouldn't a record sorter be able to do that?
18-
19-
17+
18+
# Argument parser setup
2019
parser = argparse.ArgumentParser()
21-
parser.add_argument("endpoint",
22-
help="Endpoint for connection to neo4J prod")
23-
parser.add_argument("usr",
24-
help="username")
25-
parser.add_argument("pwd",
26-
help="password")
27-
parser.add_argument("--import_filepath",
28-
help="path to file usable for writing to DB via tsv", default='')
20+
parser.add_argument("endpoint", help="Endpoint for connection to neo4J prod")
21+
parser.add_argument("usr", help="username")
22+
parser.add_argument("pwd", help="password")
23+
parser.add_argument("--import_filepath", help="path to file usable for writing to DB via tsv", default='')
2924
parser.add_argument("--base_path", help="Optional", default="../")
3025
parser.add_argument("--test_mode", help="Optional", action='store_true', default=False)
31-
parser.add_argument("--commit", help="Optional", action='store_true', default=False)
32-
parser.add_argument("--verbose", help="Optional", action='store_true', default=False)
33-
parser.add_argument("--allow_duplicates", help="Optional", action='store_true', default=False)
26+
parser.add_argument("--commit", help="Optional", action='store_true', default=False)
27+
parser.add_argument("--verbose", help="Optional", action='store_true', default=False)
28+
parser.add_argument("--allow_duplicates", help="Optional", action='store_true', default=False)
29+
parser.add_argument("--debug", help="Enable debug logging", action='store_true', default=False)
3430
args = parser.parse_args()
3531

36-
37-
38-
def check_records(path, check_dir = "working"):
39-
rec_path = '/'.join([args.base_path, path, check_dir]) + '/'
40-
recs = get_recs(spec_path="../records/" + path,
41-
path_to_recs=rec_path)
42-
stat = True
43-
if len(recs) == 0:
44-
print("No records to check in: " + rec_path)
45-
else:
46-
print("Testing syntax of %s curation records." % len(recs))
47-
if False in recs:
48-
stat = False
49-
return stat
50-
51-
52-
53-
def load_records(path, load_dir = "to_submit"):
54-
rec_path = os.path.abspath(os.path.join(args.base_path, path, load_dir))
55-
current_dir = os.path.dirname(os.path.realpath(__file__))
56-
records_path = os.path.abspath(os.path.join(current_dir, "../records", path))
57-
stat = load_recs(records_path + '/', rec_path + '/',
58-
args.endpoint, args.usr, args.pwd, import_filepath=args.import_filepath,
59-
commit=args.commit, verbose=args.verbose, allow_duplicates=args.allow_duplicates)
60-
return stat
61-
32+
# Configure logging
33+
if args.debug:
34+
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
35+
elif args.verbose:
36+
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
37+
else:
38+
logging.basicConfig(level=logging.WARNING, format='%(asctime)s - %(levelname)s - %(message)s')
39+
40+
def check_records(path, check_dir="working"):
41+
"""
42+
Checks the records in the specified directory.
43+
44+
Parameters:
45+
path (str): The base path to check records in.
46+
check_dir (str): The directory within the base path to check records in.
47+
48+
Returns:
49+
bool: True if records pass the check, False otherwise.
50+
"""
51+
try:
52+
logging.debug("Starting check_records with path: %s and check_dir: %s", path, check_dir)
53+
rec_path = '/'.join([args.base_path, path, check_dir]) + '/'
54+
logging.debug("Constructed rec_path: %s", rec_path)
55+
56+
recs = get_recs(spec_path="../records/" + path, path_to_recs=rec_path)
57+
logging.debug("Retrieved records: %s", recs)
58+
59+
stat = True
60+
if len(recs) == 0:
61+
logging.info("No records to check in: %s", rec_path)
62+
else:
63+
logging.info("Testing syntax of %s curation records.", len(recs))
64+
65+
if False in recs:
66+
logging.warning("Some records failed the check.")
67+
stat = False
68+
69+
return stat
70+
71+
except Exception as e:
72+
logging.error("An error occurred in check_records: %s", e, exc_info=True)
73+
return False
74+
75+
def load_records(path, load_dir="to_submit"):
76+
"""
77+
Loads the records from the specified directory.
78+
79+
Parameters:
80+
path (str): The base path to load records from.
81+
load_dir (str): The directory within the base path to load records from.
82+
83+
Returns:
84+
bool: True if records are successfully loaded, False otherwise.
85+
"""
86+
try:
87+
logging.debug("Starting load_records with path: %s and load_dir: %s", path, load_dir)
88+
rec_path = os.path.abspath(os.path.join(args.base_path, path, load_dir))
89+
logging.debug("Constructed rec_path: %s", rec_path)
90+
91+
current_dir = os.path.dirname(os.path.realpath(__file__))
92+
records_path = os.path.abspath(os.path.join(current_dir, "../records", path))
93+
logging.debug("Constructed records_path: %s", records_path)
94+
95+
stat = load_recs(records_path + '/', rec_path + '/',
96+
args.endpoint, args.usr, args.pwd, import_filepath=args.import_filepath,
97+
commit=args.commit, verbose=args.verbose, allow_duplicates=args.allow_duplicates)
98+
99+
logging.debug("load_recs returned status: %s", stat)
100+
return stat
101+
102+
except Exception as e:
103+
logging.error("An error occurred in load_records: %s", e, exc_info=True)
104+
return False
62105

63106
stat = True
64107

65-
66108
if not check_records(path="new_metadata/"): stat = False
67109
if not load_records(path="new_metadata/"): stat = False
68110
if not check_records(path="new_images/"): stat = False
69111
if not load_records(path="new_images/"): stat = False
112+
if not check_records(path="new_splits/"): stat = False
113+
if not load_records(path="new_splits/"): stat = False
70114

71115
if not stat:
72116
raise Exception("Failing records. See preceding warnings for details.")
@@ -77,8 +121,9 @@ def load_records(path, load_dir = "to_submit"):
77121
print("Running record syntax fails tests")
78122
check_records(path="new_metadata/", check_dir="test_syntax_fail")
79123
check_records(path="new_images/", check_dir="test_syntax_fail")
124+
# check_records(path="new_splits/", check_dir="test_syntax_fail")
125+
80126
print("Running fail tests.")
81127
load_records(path="new_metadata/", load_dir="test_load_fail")
82128
load_records(path="new_images/", load_dir="test_load_fail")
83-
84-
129+
# load_records(path="new_splits/", load_dir="test_load_fail")

0 commit comments

Comments
 (0)