Skip to content

Commit

Permalink
fix broken rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
northdpole committed May 31, 2024
1 parent b26001a commit ee3fe29
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
web: gunicorn cre:app --log-file=-g
web: gunicorn cre:app
worker: FLASK_APP=`pwd`/cre.py python cre.py --start_worker
9 changes: 4 additions & 5 deletions application/cmd/cre_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ def parse_file(
else (
defs.Code
if doctype == defs.Credoctypes.Code.value
else defs.Tool
if doctype == defs.Credoctypes.Tool.value
else None
else defs.Tool if doctype == defs.Credoctypes.Tool.value else None
)
)
document = from_dict(
Expand Down Expand Up @@ -247,7 +245,9 @@ def register_standard(
)
for node in standard_entries:
if not node:
logger.info(f"encountered empty node while importing {standard_entries[0].name}")
logger.info(
f"encountered empty node while importing {standard_entries[0].name}"
)
continue
register_node(node, collection)
if node.embeddings:
Expand Down Expand Up @@ -323,7 +323,6 @@ def parse_standards_from_spreadsheeet(
logger.info(f"Importing {len(docs.get(defs.Credoctypes.CRE.value))} CREs")
with alive_bar(len(docs.get(defs.Credoctypes.CRE.value))) as bar:
for cre in docs.pop(defs.Credoctypes.CRE.value):

register_cre(cre, collection)
bar()

Expand Down
13 changes: 7 additions & 6 deletions application/database/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
FeatureNotSupported,
NodeClassAlreadyDefined,
)
from neomodel import core
import neo4j
from sqlalchemy.orm import aliased
import os
Expand Down Expand Up @@ -580,9 +579,9 @@ def gap_analysis(self, name_1, name_2):
# """
# OPTIONAL MATCH (BaseStandard:NeoStandard {name: $name1})
# OPTIONAL MATCH (CompareStandard:NeoStandard {name: $name2})
# OPTIONAL MATCH p = allShortestPaths((BaseStandard)-[*..20]-(CompareStandard))
# OPTIONAL MATCH p = allShortestPaths((BaseStandard)-[*..20]-(CompareStandard))
# WITH p
# WHERE length(p) > 1 AND ALL(n in NODES(p) WHERE (n:NeoCRE or n = BaseStandard or n = CompareStandard) AND NOT n.name in $denylist)
# WHERE length(p) > 1 AND ALL(n in NODES(p) WHERE (n:NeoCRE or n = BaseStandard or n = CompareStandard) AND NOT n.name in $denylist)
# RETURN p
# """,
{"name1": name_1, "name2": name_2, "denylist": denylist},
Expand All @@ -600,9 +599,9 @@ def gap_analysis(self, name_1, name_2):
# """
# OPTIONAL MATCH (BaseStandard:NeoStandard {name: $name1})
# OPTIONAL MATCH (CompareStandard:NeoStandard {name: $name2})
# OPTIONAL MATCH p = allShortestPaths((BaseStandard)-[:(LINKED_TO|AUTOMATICALLY_LINKED_TO|CONTAINS)*..20]-(CompareStandard))
# OPTIONAL MATCH p = allShortestPaths((BaseStandard)-[:(LINKED_TO|AUTOMATICALLY_LINKED_TO|CONTAINS)*..20]-(CompareStandard))
# WITH p
# WHERE length(p) > 1 AND ALL(n in NODES(p) WHERE (n:NeoCRE or n = BaseStandard or n = CompareStandard) AND NOT n.name in $denylist)
# WHERE length(p) > 1 AND ALL(n in NODES(p) WHERE (n:NeoCRE or n = BaseStandard or n = CompareStandard) AND NOT n.name in $denylist)
# RETURN p
# """,
{"name1": name_1, "name2": name_2, "denylist": denylist},
Expand Down Expand Up @@ -1481,7 +1480,9 @@ def add_node(
self.session.commit()
return entry
else:
logger.info(f"did not know of {dbnode.name}:{dbnode.section}:{dbnode.section_id} ,adding")
logger.info(
f"did not know of {dbnode.name}:{dbnode.section}:{dbnode.section_id} ,adding"
)
self.session.add(dbnode)
self.session.commit()
if self.graph:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface DocumentNode {
hasLinktypeRelatedParent?: Boolean;
}

const linkTypesToNest = [TYPE_IS_PART_OF, TYPE_RELATED,TYPE_AUTOLINKED_TO];
const linkTypesToNest = [TYPE_IS_PART_OF, TYPE_RELATED, TYPE_AUTOLINKED_TO];
const linkTypesExcludedInNesting = [TYPE_CONTAINS];
const linkTypesExcludedWhenNestingRelatedTo = [TYPE_RELATED, TYPE_IS_PART_OF, TYPE_CONTAINS];

Expand Down
4 changes: 2 additions & 2 deletions application/prompt_client/prompt_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def get_content(self, url):
page.close()
return text
except requests.exceptions.RequestException as e:
print(f"Error fetching content for URL: {url} - {str(e)}")
logger.error(f"Error fetching content for URL: {url} - {str(e)}")
return ""
except playwright._impl._api_types.TimeoutError as te:
print(
logger.error(
f"Page: {url}, took too long to load, playwright timedout, trying again - {str(te)}, attempt num {attempts}"
)

Expand Down
6 changes: 3 additions & 3 deletions application/prompt_client/vertex_prompt_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def __init__(self) -> None:
if os.environ.get("SERVICE_ACCOUNT_CREDENTIALS"):
with open(service_account_secrets_file, "w") as f:
f.write(os.environ.get("SERVICE_ACCOUNT_CREDENTIALS"))
os.environ[
"GOOGLE_APPLICATION_CREDENTIALS"
] = service_account_secrets_file
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = (
service_account_secrets_file
)
elif not os.environ.get("GCP_NATIVE"):
logger.fatal(
"neither GCP_NATIVE nor SERVICE_ACCOUNT_CREDENTIALS have been set"
Expand Down
4 changes: 3 additions & 1 deletion application/utils/gap_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ def preload(target_url: str):
if f"{sb}->{sa}" in waiting:
waiting.remove(f"{sb}->{sa}")
if forward and backward:
print(f"removing standard {sb} from the waiting list as it has returned ")
print(
f"removing standard {sb} from the waiting list as it has returned "
)
standards.remove(sb)
print(f"calculating {len(waiting)} gap analyses")
time.sleep(30)
Expand Down
12 changes: 6 additions & 6 deletions application/utils/spreadsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ def __add_cre_to_spreadsheet(
for i in range(0, maxgroups):
if not working_array[defs.ExportFormat.linked_cre_id_key(str(i))]:
grp_added = True
working_array[
defs.ExportFormat.linked_cre_id_key(str(i))
] = link.document.id
working_array[
defs.ExportFormat.linked_cre_name_key(str(i))
] = link.document.name
working_array[defs.ExportFormat.linked_cre_id_key(str(i))] = (
link.document.id
)
working_array[defs.ExportFormat.linked_cre_name_key(str(i))] = (
link.document.name
)
working_array[
defs.ExportFormat.linked_cre_link_type_key(str(i))
] = link.ltype.value
Expand Down
20 changes: 11 additions & 9 deletions application/utils/spreadsheet_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def is_empty(value: Optional[str]) -> bool:

def recurse_print_links(cre: defs.Document) -> None:
for link in cre.links:
pprint(link.document)
print(link.document)
recurse_print_links(link.document)


Expand Down Expand Up @@ -455,9 +455,7 @@ def parse_hierarchical_export_format(
logger.info("Spreadsheet is hierarchical export format")
documents: Dict[str, List[defs.Document]] = {defs.Credoctypes.CRE.value: []}
cre_dict = {}
uninitialized_cre_mappings: List[
UninitializedMapping
] = (
uninitialized_cre_mappings: List[UninitializedMapping] = (
[]
) # the csv has a column "Link to Other CRE", this column linksa complete CRE entry to another CRE by name.
# The other CRE might not have been initialized yet at the time of linking so it cannot be part of our main document collection yet
Expand Down Expand Up @@ -509,9 +507,9 @@ def parse_hierarchical_export_format(
if cre:
cre_dict = update_cre_in_links(cre_dict, cre)

mapping[
"Link to other CRE"
] = f'{mapping["Link to other CRE"]},{",".join(cre.tags)}'
mapping["Link to other CRE"] = (
f'{mapping["Link to other CRE"]},{",".join(cre.tags)}'
)

if not is_empty(str(mapping.get("Link to other CRE")).strip()):
other_cres = list(
Expand All @@ -526,7 +524,9 @@ def parse_hierarchical_export_format(
for other_cre in other_cres:
logger.info(f"{cre.id}: Found 'other cre' {other_cre}")
if not cre_dict.get(other_cre):
logger.info(f"{cre.id}: We don't know yet of 'other cre' {other_cre}, adding to uninitialized mappings")
logger.info(
f"{cre.id}: We don't know yet of 'other cre' {other_cre}, adding to uninitialized mappings"
)
uninitialized_cre_mappings.append(
UninitializedMapping(
complete_cre=cre,
Expand All @@ -535,7 +535,9 @@ def parse_hierarchical_export_format(
)
)
else:
logger.info(f"{cre.id}: We knew yet 'other cre' {other_cre}, adding regular link")
logger.info(
f"{cre.id}: We knew yet 'other cre' {other_cre}, adding regular link"
)
new_cre = cre_dict[other_cre.strip()]
# we only need a shallow copy here
cre = cre.add_link(
Expand Down
1 change: 0 additions & 1 deletion application/web/web_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
from application.utils.spreadsheet import write_csv
import oauthlib
import google.auth.transport.requests
from application.utils.hash import make_array_hash, make_cache_key

from application import tracer

Expand Down
3 changes: 1 addition & 2 deletions cre.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
app = create_app(mode=os.getenv("FLASK_CONFIG") or "default")
migrate = Migrate(app, sqla, render_as_batch=True)

# flask <x> commands


# flask <x> commands
@app.cli.command() # type: ignore
@click.option(
"--cover/--no-cover", default=False, help="Run tests under code coverage."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2024-03-24 13:56:58.321752
"""

from alembic import op
import sqlalchemy as sa

Expand Down

0 comments on commit ee3fe29

Please sign in to comment.