Skip to content
Merged
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
28 changes: 28 additions & 0 deletions docs/release-notes/6.2.39.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# pyegeria 6.2.39

pyegeria 6.2.39 fixes how Dr.Egeria reads list attributes. It also carries the two 6.2.38 fixes (the DCAT Catalog spec runs with a search string; My Egeria's domain selection passes the GUID): 6.2.38 was tagged but not published to PyPI, so 6.2.39 follows 6.2.37 there. See 6.2.38.md.

## Fixed

- **A bullet containing a comma was split into two items.** Dr.Egeria split every list attribute's value (`Simple
List`, `List`, `NameList`, `Reference Name List`, in both the v2 parser and the older md_processing path) on
commas, semicolons and newlines. A bullet such as "Results go to the Service Owner and the depending domain, not
only to IT" became two items. The CDO workbook's IT governance metric "Recovery Test Coverage" was stored with 6
implications instead of 4.
- Now a bulleted or multi-line value is one item per bullet (or line), verbatim, with the leading `- `, `* ` or
`+ ` removed.
- A single-line value is still split on commas and semicolons ("a, b" is two items), including an inline
bulleted list on one line ("- a; - b, c" is three).
- **Behaviour change:** a single bullet on its own line, such as "- a, b", is now one item (it used to be two).
- In a block with bullets, an indented line, or a line starting in lower case after an unfinished bullet, is
that bullet's wrapped continuation; an intro line before the first bullet, or a closing sentence after the
bullets, is its own item.
- A block without bullets is one item per line (a short line stands alone, even in lower case), unless it is
clearly wrapped prose -- every line but the last at least 60 characters long and not ending a sentence --
which is one item.
- Spec metadata (labels, valid values) is parsed as before.
- **Write list values as bullets**, one item per bullet: that is the form Dr.Egeria reads unambiguously.

**Correcting stored data:** re-run the affected Dr.Egeria documents. An Update (or a Create that becomes an Update)
sends the whole list with `mergeUpdate: true`, and Egeria's merge update replaces a property's value as a whole, so
the list is replaced, not appended. A list attribute left out of the document is not changed.
7 changes: 4 additions & 3 deletions md_processing/md_processing_utils/common_md_proc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from md_processing.md_processing_utils.common_md_utils import (
get_current_datetime_string,
split_tb_string,
split_list_value,
str_to_bool,
normalize_value,
print_msg,
Expand Down Expand Up @@ -422,7 +423,7 @@ def parse_upsert_command(egeria_client: EgeriaTech, object_type: str, object_act
)
name_list = parsed_attributes[key]['value']
# attribute = re.split(r'[;,\n]+', name_list) if name_list is not None else None
attribute = split_tb_string(name_list)
attribute = split_list_value(name_list) # 6.2.39: a bullet is one item
parsed_attributes[key]['value'] = attribute
parsed_attributes[key]['name_list'] = name_list
elif style == 'Parent':
Expand Down Expand Up @@ -729,7 +730,7 @@ def _to_snake_case(name: str) -> str:
)
name_list = parsed_attributes[key]['value']
# attribute = re.split(r'[;,\n]+', name_list) if name_list is not None else None
attribute = split_tb_string(name_list)
attribute = split_list_value(name_list) # 6.2.39: a bullet is one item
parsed_attributes[key]['value'] = attribute
parsed_attributes[key]['name_list'] = name_list
elif style == 'Parent':
Expand Down Expand Up @@ -1342,7 +1343,7 @@ def proc_name_list(egeria_client: EgeriaTech, element_type: str, txt: str, eleme
return {"status": if_missing, "reason": msg, "value": None, "valid": False, "exists": False, }
else:
# element_list = re.split(r'[;,\n]+', elements_txt)
element_list = split_tb_string(elements_txt)
element_list = split_list_value(elements_txt) # 6.2.39: a bullet is one name
element_details = {}
for element in element_list:
# Get the element using the generalized function
Expand Down
76 changes: 76 additions & 0 deletions md_processing/md_processing_utils/common_md_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,82 @@ def split_tb_string(input: str)-> [Any]:
results.append(item)
return results

_LIST_BULLET = re.compile(r'^\s*[\-\*\+]\s+')
#: A separator followed by another bullet marker: an inline list on one line ("- a; - b, c").
_INLINE_BULLETS = re.compile(r'[;,]\s*[\-\*\+]\s+')


def split_list_value(text: Any) -> list | None:
"""The items of a list attribute's VALUE (Simple List, List, NameList, Reference Name List).

- A bulleted or multi-line value: each bullet (or line) is one item, verbatim -- a comma inside a
bullet is part of the item ("- agreed with the depending domain, not set by IT alone" is one
item). A leading markdown bullet (`- `, `* `, `+ `) is stripped. Wrapped continuations and
wrapped prose are handled by `_split_multiline`.
- A single-line value is split on commas and semicolons ("a, b" is two items), including an inline
bulleted list on one line ("- a; - b, c" is three); a single bullet on its own line is one item.

Until 6.2.39 every value was split on commas, semicolons and newlines, so a bullet with a comma
became two items. Spec metadata (labels, valid values) still uses `split_tb_string`.
"""
if text is None:
return None
if isinstance(text, (list, tuple)):
return [str(i).strip() for i in text if str(i).strip()]
lines = [line for line in str(text).splitlines() if line.strip()]
if not lines:
return []
if len(lines) > 1:
return _split_multiline(lines)
line = lines[0]
if _LIST_BULLET.match(line) and not _INLINE_BULLETS.search(line):
return [_LIST_BULLET.sub('', line).strip()] # one bullet: one item, commas and all
items = [_LIST_BULLET.sub('', item).strip() for item in re.split(r'[;,]+', line)]
return [item for item in items if item]


_SENTENCE_END = re.compile(r'[.!?;:]["\')\]]*$')
#: A wrapped line is at least this long; a shorter line that ends without punctuation stands alone.
_WRAP_WIDTH = 60


def _continues(previous: str, line: str) -> bool:
"""Whether a non-bullet `line` after a bullet is that bullet's wrapped continuation: indented, or
starting in lower case after a bullet that did not end its sentence. Anything else stands alone."""
if line[:1].isspace():
return True
return line.lstrip()[:1].islower() and not _SENTENCE_END.search(previous.rstrip())


def _split_multiline(lines: list) -> list:
"""Items of a multi-line list value (6.2.39):

- **With bullets:** each bullet is an item. A non-bullet line after a bullet joins it when it is a
wrapped continuation (indented, or starting in lower case); otherwise -- a closing sentence, say
-- it is its own item. Lines before the first bullet (an intro) are their own items.
- **Without bullets:** clearly wrapped prose -- every line but the last is at least 60 characters
long and does not end a sentence (. ! ? ; :) -- is one item, its lines joined with spaces. Otherwise
each line is an item (a line list): a short line, even in lower case ("crm", "erp", "data
quality"), stands alone.
Commas are never split inside a multi-line value."""
if not any(_LIST_BULLET.match(line) for line in lines):
if all(not _SENTENCE_END.search(a.rstrip()) and len(a.rstrip()) >= _WRAP_WIDTH for a in lines[:-1]):
return [" ".join(line.strip() for line in lines)]
return [line.strip() for line in lines if line.strip()]
items: list = []
in_bullet = False
for line in lines:
if _LIST_BULLET.match(line):
items.append(_LIST_BULLET.sub('', line).strip())
in_bullet = True
elif in_bullet and _continues(items[-1], line):
items[-1] = f"{items[-1]} {line.strip()}"
else:
items.append(line.strip())
in_bullet = False
return [item for item in items if item]


def str_to_bool(value: str) -> bool:
"""Converts a string to a boolean value."""
return value.lower() in ("yes", "true", "t", "1")
Expand Down
14 changes: 4 additions & 10 deletions md_processing/v2/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import pyegeria.core._globals as pyeg_globals
from md_processing.md_processing_utils.md_processing_constants import get_command_spec, load_commands
import md_processing.md_processing_utils.md_processing_constants as md_constants
from md_processing.md_processing_utils.common_md_utils import normalize_value
from md_processing.md_processing_utils.common_md_utils import normalize_value, split_list_value
from .extraction import DrECommand
from .utils import parse_key_value, parse_line_list, parse_table

Expand Down Expand Up @@ -416,15 +416,9 @@ async def _process_attribute_value(self, value: str, details: dict) -> Any:
return v

elif style in {"List", "NameList", "Simple List", "Reference Name List"}:
items = re.split(r'[;,\n]+', value)
results = []
for item in items:
item = item.strip()
if item:
# Strip leading markdown bullet if present
item = re.sub(r'^[\-\*\+]\s*', '', item)
results.append(item)
return results
# 6.2.39: a bulleted or multi-line value is one item per bullet, verbatim (a comma inside a
# bullet stays in it); only a single-line value is split on commas and semicolons.
return split_list_value(value)

return value

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[project]
name = "pyegeria"
version = "6.2.38"
version = "6.2.39"
license = 'Apache-2.0'
license-files = ["LICENSE"]
authors = [{name = "Dan Wolfson", email = "dan.wolfson@pdr-associates.com"},]
Expand Down
3 changes: 3 additions & 0 deletions tests/micro-tests/data/dr_egeria/glossary_usage.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This glossary is used by data architects and data stewards when naming new data fields. Build a field name by
combining a prime word (from the relevant subject area), zero or more modifiers (from the subject area or the
Common Modifiers folder), and a class word (from the subject area or the Common Class Words folder).
89 changes: 89 additions & 0 deletions tests/micro-tests/data/dr_egeria/it_governance_program_excerpt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<!-- Two real Dr.Egeria commands, copied verbatim from egeria-workspaces coco-workbooks/4. keeping-safe/it-governance-program.md (lines 35-79 and 618-656, egeria-workspaces-fs 564de8f0) for the 6.2.39 list-attribute test. -->

## Create Business Imperative

### Display Name
Digital Services the Business Can Depend On

### Qualified Name
CocoPharma::BusinessImperative::DependableDigitalServices

### Domain Identifier
IT Infrastructure

### Summary
Coco Pharmaceuticals must run digital services whose availability, change behaviour, and recovery characteristics are known and agreed, so that the domains depending on them can make commitments of their own.

### Description
Every regulatory commitment the company makes is, somewhere underneath, a commitment about a system. A batch cannot be released if the electronic batch record system is unavailable; a data subject request cannot be answered in a month if the systems holding the data cannot be searched; expedited safety reporting cannot meet a seven-day deadline through a manual workaround. What the business needs from this domain is not maximal availability everywhere, which is unaffordable, but *known* characteristics — an agreed service level, an understood recovery time, and a change process that does not surprise the people who depend on the service. This imperative is deliberately expressed as dependability rather than uptime, because a service that is reliably available four days a week is more useful to plan around than one that is usually available and occasionally not. The measure of success is that other domains can state their own commitments with confidence, not that this domain reports high availability figures.

### Implications
- Service characteristics must be agreed with the depending domain, not set by IT alone
- Recovery objectives must reflect what the business actually needs, which differs sharply by service
- Change behaviour must be predictable, since unpredictability is itself an availability problem
- Investment must be justified by the obligations it lets other domains discharge

### Outcomes
- Domains can make regulatory and business commitments knowing what they rest on
- Service investment is directed by consequence rather than by uniform standards
- Unplanned change ceases to be a source of compliance failure in other domains

### Importance
High

### Category
IT Infrastructure

### Authors
Gary Geeke

### Version Identifier
1.0

### Content Status
ACTIVE

___


---

## Create Governance Metric

### Display Name
Recovery Objective Test Coverage and Achievement

### Qualified Name
CocoPharma::GovernanceMetric::RecoveryTestCoverage

### Domain Identifier
IT Infrastructure

### Summary
Measures the percentage of services with a recovery objective that have been exercised within their test cycle, and the proportion of those exercises that met the agreed objective.

### Description
Coverage and achievement are separate questions and both matter. Coverage asks whether the exercise happened; achievement asks whether the tested recovery met what the depending domain was promised. A service with high coverage and poor achievement is honestly reported and correctable; one with poor coverage is a service whose stated objective is unverified, and unverified objectives are the ones that fail during an actual incident. Reporting is per service and goes to the Service Owner and the depending domain rather than only to the infrastructure team, which is the arrangement that makes a shortfall actionable by the people it affects. Services supporting regulatory deadlines — batch release, safety reporting, data subject requests — are reported separately because a recovery shortfall there converts directly into a missed statutory obligation. Where achievement falls persistently short and the gap cannot be closed economically, the metric is the evidence for renegotiating the objective rather than continuing to report failure against a target nobody can meet.

### Implications
- Coverage and achievement are distinct measures and both are required
- Results go to the Service Owner and the depending domain, not only to IT
- Services supporting regulatory deadlines are reported separately
- Persistent shortfall is evidence for renegotiating the objective, not for repeated failure reporting

### Outcomes
- Stated recovery objectives are verified rather than assumed
- Depending domains learn of shortfalls before an incident reveals them
- Objectives converge on what can actually be delivered

### Authors
Gary Geeke

### Version Identifier
1.0

### Content Status
ACTIVE

___

5 changes: 5 additions & 0 deletions tests/micro-tests/data/dr_egeria/samples_examples.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

Create Glossary or
Update Glossary or
Create Term or
Update Term
7 changes: 7 additions & 0 deletions tests/micro-tests/data/dr_egeria/samples_mixed_examples.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Default values for key environment variables in the **Egeria Workspaces** environment:
* EGERIA_ROOT_PATH=/home/jovyan
* EGERIA_INBOX_PATH=loading-bay/dr-egeria-inbox
* EGERIA_OUTBOX_PATH=distribution-hub/dr-egeria-outbox
* EGERIA_LOCAL_QUALIFIER=EGERIA

So place input files in the `loading-bay/dr-egeria-inbox` folder and look for output files in `distribution-hub/dr-egeria-outbox`.
Loading
Loading