darabos commited on
Commit
20ee52e
·
1 Parent(s): e5ef389

Fix Griffe warnings.

Browse files
examples/uploads/lynx_chatbot_scenario_selector.yaml CHANGED
@@ -42,7 +42,7 @@
42
  where appropriate. Avoid phrases like 'According to this article' to maintain a natural
43
  tone.
44
  link_answer: &link # When present, formatted node link appends to answer, should contain {link}
45
- "\n\nPlease visit <a href='{link}' target='_blank'>{link}</a> for further information."
46
  min_similarity_score: -1 # Only need to specify if > -1 and in RETRIEVE_LLM or RETRIEVE_ONLY mode
47
  - name: life_sciences_interest
48
  mode: retrieve_llm
 
42
  where appropriate. Avoid phrases like 'According to this article' to maintain a natural
43
  tone.
44
  link_answer: &link # When present, formatted node link appends to answer, should contain {link}
45
+ "\n\nPlease visit {link} for further information."
46
  min_similarity_score: -1 # Only need to specify if > -1 and in RETRIEVE_LLM or RETRIEVE_ONLY mode
47
  - name: life_sciences_interest
48
  mode: retrieve_llm
lynxkite-core/src/lynxkite/core/ops.py CHANGED
@@ -247,7 +247,7 @@ def op(
247
  """Decorator for defining an operation."""
248
 
249
  def decorator(func):
250
- doc = parse_doc(func.__doc__)
251
  sig = inspect.signature(func)
252
  _view = view
253
  if view == "matplotlib":
@@ -444,16 +444,45 @@ def run_user_script(script_path: pathlib.Path):
444
 
445
 
446
  @functools.cache
447
- def parse_doc(doc):
448
- """Griffe is an optional dependency. When available, we returned the parsed docstring."""
 
449
  try:
450
  import griffe
451
  except ImportError:
452
  return doc
453
  if doc is None:
454
  return None
 
455
  if "----" in doc:
456
- doc = griffe.Docstring(doc).parse("numpy")
457
  else:
458
- doc = griffe.Docstring(doc).parse("google")
459
- return json.loads(json.dumps(doc, cls=griffe.JSONEncoder))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  """Decorator for defining an operation."""
248
 
249
  def decorator(func):
250
+ doc = parse_doc(func)
251
  sig = inspect.signature(func)
252
  _view = view
253
  if view == "matplotlib":
 
444
 
445
 
446
  @functools.cache
447
+ def parse_doc(func):
448
+ """Griffe is an optional dependency. When available, we return the parsed docstring."""
449
+ doc = func.__doc__
450
  try:
451
  import griffe
452
  except ImportError:
453
  return doc
454
  if doc is None:
455
  return None
456
+ ds = griffe.Docstring(doc, parent=_get_griffe_function(func))
457
  if "----" in doc:
458
+ ds = ds.parse("numpy")
459
  else:
460
+ ds = ds.parse("google")
461
+ return json.loads(json.dumps(ds, cls=griffe.JSONEncoder))
462
+
463
+
464
+ def _get_griffe_function(func):
465
+ """Returns a griffe.Function object based on the signature of the function."""
466
+ import griffe
467
+
468
+ sig = inspect.signature(func)
469
+ parameters = []
470
+ for name, param in sig.parameters.items():
471
+ if param.annotation is inspect.Parameter.empty:
472
+ annotation = None
473
+ else:
474
+ annotation = param.annotation.__name__
475
+ parameters.append(
476
+ griffe.Parameter(
477
+ name,
478
+ annotation=annotation,
479
+ kind=griffe.ParameterKind.keyword_only
480
+ if param.kind == inspect.Parameter.KEYWORD_ONLY
481
+ else griffe.ParameterKind.positional_or_keyword,
482
+ )
483
+ )
484
+ return griffe.Function(
485
+ func.__name__,
486
+ parameters=griffe.Parameters(*parameters),
487
+ returns=str(sig.return_annotation),
488
+ )
lynxkite-graph-analytics/src/lynxkite_graph_analytics/lynxkite_ops.py CHANGED
@@ -303,7 +303,7 @@ def create_graph(bundle: core.Bundle, *, relations: str = None) -> core.Bundle:
303
  relations (str, optional): Set of relations to set for the bundle. The parameter
304
  should be a JSON object where the keys are relation names and the values are
305
  a dictionary representation of a `RelationDefinition`.
306
- Defaults to None.
307
 
308
  Returns:
309
  Bundle: The input bundle with the new relations set.
 
303
  relations (str, optional): Set of relations to set for the bundle. The parameter
304
  should be a JSON object where the keys are relation names and the values are
305
  a dictionary representation of a `RelationDefinition`.
306
+ Defaults to None.
307
 
308
  Returns:
309
  Bundle: The input bundle with the new relations set.