Skip to content

Commit b679a71

Browse files
committed
if not package_name defined do not check for pypi version
1 parent e04ebc1 commit b679a71

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/ethopy/core/logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ def update_setup_info(
758758

759759
def _log_task_details(self) -> None:
760760
"""Save the task file, name and git_hash in the database."""
761-
version_info = get_code_version_info()
761+
version_info = get_code_version_info(package_name="ethopy")
762762
self.put(table="Session.Version", tuple={**self.trial_key, **version_info})
763763
log.debug(f"Code version: {version_info}")
764764

src/ethopy/utils/helper_functions.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def convert_numeric_keys(data: Dict) -> Dict:
279279
return data
280280

281281

282-
def get_code_version_info(project_path: str = None) -> Dict[str, Any]:
282+
def get_code_version_info(project_path: str = None, package_name: str=None) -> Dict[str, Any]:
283283
"""Determine version information for a project directory.
284284
285285
Checks git hash first, then PyPI version, then returns None.
@@ -300,8 +300,8 @@ def get_code_version_info(project_path: str = None) -> Dict[str, Any]:
300300
# two_folders_back = project_path.parents[1]
301301
result = {
302302
"project_path": os.path.abspath(project_path),
303-
"source_type": None,
304-
"version": None,
303+
"source_type": 'None',
304+
"version": '',
305305
"repository_url": '',
306306
"is_dirty": False,
307307
}
@@ -379,16 +379,16 @@ def get_code_version_info(project_path: str = None) -> Dict[str, Any]:
379379
log.debug(f"Not a git repository or git error: {e}")
380380

381381
# Check if it's installed via PyPI
382-
try:
383-
# Try to get package metadata
384-
package_name = "ethopy"
385-
package_version = importlib.metadata.version(package_name)
386-
387-
result["source_type"] = "pypi"
388-
result["version"] = package_version
389-
return result
390-
except (importlib.metadata.PackageNotFoundError, ImportError) as e:
391-
log.debug(f"Not a PyPI package or error: {e}")
382+
if package_name is not None:
383+
try:
384+
# Try to get package metadata
385+
package_version = importlib.metadata.version(package_name)
386+
387+
result["source_type"] = "pypi"
388+
result["version"] = package_version
389+
return result
390+
except (importlib.metadata.PackageNotFoundError, ImportError) as e:
391+
log.debug(f"Not a PyPI package or error: {e}")
392392

393393
# If we get here, we couldn't determine version info
394394
return result

0 commit comments

Comments
 (0)