Skip to content

Enhancement to allow paths with directories. #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 1, 2025
Merged

Enhancement to allow paths with directories. #96

merged 5 commits into from
Jun 1, 2025

Conversation

paulsaxe
Copy link
Contributor

@paulsaxe paulsaxe commented Jun 1, 2025

  • As in reading/writing structures, paths beginning with '/' are relative to the root of the job, and relative paths are relative to the directory where the table step is invoked.

paulsaxe added 2 commits May 15, 2025 10:55
* As in reading/writing structures, paths beginning with '/' are relative to the
  root of the job, and relative paths are relative to the directory where the table
  step is invoked.
@paulsaxe paulsaxe requested review from seamm and Copilot June 1, 2025 16:52
@paulsaxe paulsaxe added the enhancement New feature or request label Jun 1, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances file path handling for the Table step so that absolute paths (starting with /) are resolved relative to the job root and other paths are relative to the invocation directory.

  • Update module docstring in table_parameters.py.
  • Refactor imports and implement new logic in table.py to resolve absolute vs. relative filenames.
  • Add a HIST­ORY entry documenting the change.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
table_step/table_parameters.py Corrected module docstring to reference tables instead of loops
table_step/table.py Swapped to pathlib.Path, added logic for absolute vs. relative paths, removed os.path
HISTORY.rst Recorded version 2025.6.1 with path-handling enhancement

@@ -3,8 +3,7 @@
"""Non-graphical part of the Table step in SEAMM"""

import logging
import os.path
from pathlib import PurePath
from pathlib import Path, PurePath
Copy link
Preview

Copilot AI Jun 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import of PurePath is unused in this file; consider removing it to keep imports clean.

Suggested change
from pathlib import Path, PurePath
from pathlib import Path

Copilot uses AI. Check for mistakes.

Comment on lines +210 to +211
# Pathnames are relative to current working directory
wd = Path(self.directory).parent
Copy link
Preview

Copilot AI Jun 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The variable name wd and the comment are vague. Consider renaming wd to base_dir or invocation_dir and update the comment to specify that it's the directory where the table step is invoked.

Suggested change
# Pathnames are relative to current working directory
wd = Path(self.directory).parent
# Base directory where the table step is invoked
base_dir = Path(self.directory).parent

Copilot uses AI. Check for mistakes.

Comment on lines +338 to +340
if filename.startswith("/"):
filename = str(
Path(self.flowchart.root_directory) / filename[1:]
Copy link
Preview

Copilot AI Jun 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking startswith("/") only covers POSIX-style paths. Use Path(filename).is_absolute() to handle absolute paths in a platform-independent way.

Suggested change
if filename.startswith("/"):
filename = str(
Path(self.flowchart.root_directory) / filename[1:]
if Path(filename).is_absolute():
filename = str(
Path(self.flowchart.root_directory) / Path(filename).relative_to("/")

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@seamm seamm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@seamm seamm merged commit d680570 into main Jun 1, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants