Skip to content

Commit

Permalink
Add addl packages to otter --version (#868)
Browse files Browse the repository at this point in the history
* add addl packages to otter --version

* add addl packages to otter --version

* remake poetry.lock
  • Loading branch information
chrispyles authored Oct 25, 2024
1 parent b7d038a commit 4b02102
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 43 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* Added exception-based test support for the `all_or_nothing` config per [#751](https://github.com/ucbds-infra/otter-grader/issues/751)
* Added Otter Assign support for the `all_or_nothing` config per [#751](https://github.com/ucbds-infra/otter-grader/issues/751)
* Updated Otter Assign to only allow a function definition and statement to call the test function in exception-based test cells and automatically ignore the latter statement instead of requiring an explicit `# IGNORE` comment per [#516](https://github.com/ucbds-infra/otter-grader/issues/516)
* Added additional package versions to the output of `otter --version` per [#843](https://github.com/ucbds-infra/otter-grader/issues/843)

**v5.7.1:**

Expand Down
5 changes: 2 additions & 3 deletions otter/execute/preprocessor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import ast
import astunparse
import json
import nbformat as nbf
import os
Expand Down Expand Up @@ -241,7 +240,7 @@ def visit_ImportFrom(self, node: ast.ImportFrom):
self.imports.append(node)

def to_module(self):
return ast.Module(body=self.imports)
return ast.Module(body=self.imports, type_ignores=[])

def to_script(self):
return astunparse.unparse(self.to_module())
return ast.unparse(self.to_module())
32 changes: 29 additions & 3 deletions otter/version.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Version and printable logo"""

import importlib
import sys

from textwrap import dedent
from textwrap import dedent, indent


__version__ = "5.7.1"
Expand All @@ -23,6 +24,15 @@
] # remove beginning newline


_ADDITIONAL_PACKAGES = [
"dill",
"fica",
"IPython",
"nbconvert",
"nbformat",
]


def print_version_info(logo: bool = False):
"""
Prints the Otter logo and version information to stdout
Expand All @@ -35,7 +45,23 @@ def print_version_info(logo: bool = False):
print(
dedent(
f"""\
Python version: {".".join(str(v) for v in sys.version_info[:3])}
Otter-Grader version: {__version__}"""
Python version: {".".join(str(v) for v in sys.version_info[:3])}
Otter-Grader version: {__version__}
Additional package versions:
"""
)
+ indent(_list_addl_package_versions(), " ")
)


def _list_addl_package_versions() -> str:
"""Generate a string listing versions of additional packages of interest."""
versions = []
for p in _ADDITIONAL_PACKAGES:
try:
m = importlib.import_module(p)
versions.append(f"{p}: {m.__version__}")
except Exception as e:
versions.append(f"{p}: (failed) {type(e).__name__}: {e}")
return "\n".join(versions)
43 changes: 7 additions & 36 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ gmail_oauth2 = "otter.plugins.builtin.gmail_notifications.bin.gmail_oauth2:main"

[tool.poetry.dependencies]
python = "^3.9"
astunparse = "^1.6.3"
click = "^8.1.7"
dill = "^0.3.8"
fica = ">=0.4.1"
Expand Down

0 comments on commit 4b02102

Please sign in to comment.