Skip to content
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

package_path is None if input subdirectory contains a file called config.yaml #229

Open
anjsimmo opened this issue Mar 30, 2020 · 0 comments
Assignees
Milestone

Comments

@anjsimmo
Copy link

anjsimmo commented Mar 30, 2020

Surround will automatically try to determine the package_path by searching for the directory that contains config.yaml. However, if a second config.yaml file is found (e.g. in a subdirectory of input), this will cause package_path to be None, which can cause a previously working Surround project to suddenly stop working.

Expected behaviour

  • Surround should ignore the input directory completely when searching for a config.yaml
  • Surround should search top level directories before it searches subdirectories

Actual behaviour

  • Surround walks the entire project (including the input directory) in search of a config.yaml file, no matter how deeply nested (on projects with large input directories like MSR, this adds a 20 second delay every time Surround is run, even if just to list Surround tasks)
  • Surround filters out files directly in one of the generated directories specified by PROJECTS['new']['dirs'], e.g. input/config.yaml. However, input/subdir/config.yaml will still cause problems.
  • This can cause surround run to fail for Surround projects that try to utilise CONFIG["package_path"] in their dodo.py. Example for MSR Surround project:
Project tasks:
Traceback (most recent call last):
  File "/home/andrew/anaconda3/envs/msr/lib/python3.7/site-packages/doit/doit_cmd.py", line 177, in run
    return command.parse_execute(args)
  File "/home/andrew/anaconda3/envs/msr/lib/python3.7/site-packages/doit/cmd_base.py", line 127, in parse_execute
    return self.execute(params, args)
  File "/home/andrew/anaconda3/envs/msr/lib/python3.7/site-packages/doit/cmd_base.py", line 389, in execute
    self, params, args)
  File "/home/andrew/anaconda3/envs/msr/lib/python3.7/site-packages/doit/cmd_base.py", line 281, in load_tasks
    params['seek_file'])
  File "/home/andrew/anaconda3/envs/msr/lib/python3.7/site-packages/doit/loader.py", line 95, in get_module
    return importlib.import_module(os.path.splitext(file_name)[0])
  File "/home/andrew/anaconda3/envs/msr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/andrew/src/msr-research/mining-nlp-repositories/dodo.py", line 8, in <module>
    PACKAGE_PATH = os.path.basename(CONFIG["package_path"])
  File "/home/andrew/anaconda3/envs/msr/lib/python3.7/posixpath.py", line 146, in basename
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType

Cause

https://github.com/a2i2/surround/blob/v0.0.13/surround/config.py#L199

results = [path for path, _, files in os.walk(project_root) if 'config.yaml' in files]
results = [path for path in results if os.path.basename(path) not in PROJECTS['new']['dirs']]

return results[0] if len(results) == 1 else None
@ScottyB ScottyB added this to the 0.0.15 milestone Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants