refscan 0.1.1__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {refscan-0.1.1 → refscan-0.1.2}/PKG-INFO +2 -2
- {refscan-0.1.1 → refscan-0.1.2}/README.md +1 -1
- {refscan-0.1.1 → refscan-0.1.2}/pyproject.toml +1 -1
- refscan-0.1.2/refscan/__init__.py +18 -0
- {refscan-0.1.1 → refscan-0.1.2}/refscan/refscan.py +15 -8
- refscan-0.1.1/refscan/__init__.py +0 -11
- {refscan-0.1.1 → refscan-0.1.2}/refscan/lib/Finder.py +0 -0
- {refscan-0.1.1 → refscan-0.1.2}/refscan/lib/Reference.py +0 -0
- {refscan-0.1.1 → refscan-0.1.2}/refscan/lib/ReferenceList.py +0 -0
- {refscan-0.1.1 → refscan-0.1.2}/refscan/lib/Violation.py +0 -0
- {refscan-0.1.1 → refscan-0.1.2}/refscan/lib/ViolationList.py +0 -0
- {refscan-0.1.1 → refscan-0.1.2}/refscan/lib/constants.py +0 -0
- {refscan-0.1.1 → refscan-0.1.2}/refscan/lib/helpers.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: refscan
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Command-line program that scans the NMDC MongoDB database for referential integrity violations
|
|
5
5
|
Home-page: https://github.com/microbiomedata/refscan
|
|
6
6
|
Keywords: mongodb,mongo,relationships,reference,database,data,referential integrity,scan
|
|
@@ -240,7 +240,7 @@ That package will have a version identifier that matches the name of the Git tag
|
|
|
240
240
|
|
|
241
241
|
The GitHub Actions workflow will automatically
|
|
242
242
|
|
|
243
|
-
###
|
|
243
|
+
### Test the build process locally
|
|
244
244
|
|
|
245
245
|
In case you want to test the build process locally, you can do so by running:
|
|
246
246
|
|
|
@@ -221,7 +221,7 @@ That package will have a version identifier that matches the name of the Git tag
|
|
|
221
221
|
|
|
222
222
|
The GitHub Actions workflow will automatically
|
|
223
223
|
|
|
224
|
-
###
|
|
224
|
+
### Test the build process locally
|
|
225
225
|
|
|
226
226
|
In case you want to test the build process locally, you can do so by running:
|
|
227
227
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from importlib.metadata import metadata, PackageMetadata, PackageNotFoundError
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def get_package_metadata(key: str) -> str:
|
|
5
|
+
r"""
|
|
6
|
+
Returns metadata about the installed package.
|
|
7
|
+
|
|
8
|
+
References:
|
|
9
|
+
- https://docs.python.org/3/library/importlib.metadata.html#distribution-metadata
|
|
10
|
+
- https://github.com/python-poetry/poetry/issues/273#issuecomment-570999678
|
|
11
|
+
"""
|
|
12
|
+
metadata_value = ""
|
|
13
|
+
try:
|
|
14
|
+
package_metadata: PackageMetadata = metadata("refscan")
|
|
15
|
+
metadata_value = package_metadata.get(key)
|
|
16
|
+
except PackageNotFoundError:
|
|
17
|
+
pass
|
|
18
|
+
return metadata_value
|
|
@@ -26,10 +26,12 @@ app = typer.Typer(
|
|
|
26
26
|
rich_markup_mode="markdown", # enables use of Markdown in docstrings and CLI help
|
|
27
27
|
)
|
|
28
28
|
|
|
29
|
+
app_version = get_package_metadata("Version")
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
|
|
32
|
+
def display_app_version_and_exit(is_active: bool = False) -> None:
|
|
31
33
|
r"""
|
|
32
|
-
Displays the version number
|
|
34
|
+
Displays the app's version number, then exists.
|
|
33
35
|
|
|
34
36
|
Note: The `is_active` flag will be `True` if the program was
|
|
35
37
|
invoked with the associated CLI option.
|
|
@@ -37,8 +39,7 @@ def show_project_version_and_exit(is_active: bool = False) -> None:
|
|
|
37
39
|
Reference: https://typer.tiangolo.com/tutorial/options/version/
|
|
38
40
|
"""
|
|
39
41
|
if is_active:
|
|
40
|
-
|
|
41
|
-
console.print(f"[white]{version}[/white]")
|
|
42
|
+
console.print(f"[white]{app_version}[/white]")
|
|
42
43
|
raise typer.Exit()
|
|
43
44
|
|
|
44
45
|
|
|
@@ -90,7 +91,7 @@ def scan(
|
|
|
90
91
|
)] = "violations.tsv",
|
|
91
92
|
version: Annotated[Optional[bool], typer.Option(
|
|
92
93
|
"--version",
|
|
93
|
-
callback=
|
|
94
|
+
callback=display_app_version_and_exit,
|
|
94
95
|
is_eager=True, # tells Typer to process this option first
|
|
95
96
|
help="Show version number and exit.",
|
|
96
97
|
)] = None,
|
|
@@ -103,9 +104,11 @@ def scan(
|
|
|
103
104
|
console.print(f"Schema YAML file: {schema_file_path}")
|
|
104
105
|
schema_view = linkml_runtime.SchemaView(schema_file_path)
|
|
105
106
|
|
|
106
|
-
# Show high-level information about the
|
|
107
|
-
console.print(f"
|
|
108
|
-
console.print(f"
|
|
107
|
+
# Show high-level information about the application and schema.
|
|
108
|
+
console.print(f"refscan version: {app_version}")
|
|
109
|
+
console.print(f"Schema version: {schema_view.schema.version}")
|
|
110
|
+
|
|
111
|
+
console.rule("[bold]Identifying references")
|
|
109
112
|
|
|
110
113
|
# Make a more self-documenting alias for the CLI option that can be specified multiple times.
|
|
111
114
|
names_of_source_collections_to_skip: list[str] = [] if skip_source_collection is None else skip_source_collection
|
|
@@ -181,6 +184,8 @@ def scan(
|
|
|
181
184
|
if verbose:
|
|
182
185
|
console.print(references.as_table())
|
|
183
186
|
|
|
187
|
+
console.rule("[bold]Scanning for violations")
|
|
188
|
+
|
|
184
189
|
# Get a dictionary that maps source class names to the names of their fields that can contain references.
|
|
185
190
|
reference_field_names_by_source_class_name = references.get_reference_field_names_by_source_class_name()
|
|
186
191
|
|
|
@@ -314,6 +319,8 @@ def scan(
|
|
|
314
319
|
# Close the connection to the MongoDB server.
|
|
315
320
|
mongo_client.close()
|
|
316
321
|
|
|
322
|
+
console.rule("[bold]Results summary")
|
|
323
|
+
|
|
317
324
|
# Create a violation report in TSV format — for all collections combined.
|
|
318
325
|
all_violations = ViolationList()
|
|
319
326
|
for collection_name, violations in sorted(source_collections_and_their_violations.items(), key=get_lowercase_key):
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import importlib.metadata
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def get_package_metadata(key: str) -> str:
|
|
5
|
-
r"""
|
|
6
|
-
Returns metadata about the installed package.
|
|
7
|
-
|
|
8
|
-
Reference: https://github.com/python-poetry/poetry/issues/273#issuecomment-570999678
|
|
9
|
-
"""
|
|
10
|
-
package_metadata = importlib.metadata.metadata("refscan")
|
|
11
|
-
return package_metadata[key] if key in package_metadata else ""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|