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

GHA: Run tests on windows-latest, macos-latest, ubuntu-latest #91

Merged
merged 26 commits into from
Nov 29, 2021

Conversation

dweindl
Copy link
Member

@dweindl dweindl commented Nov 29, 2021

  • Run test suite on windows-latest, macos-latest, ubuntu-latest
  • Fixed various issues related to temporary files on Windows
  • Add support for pathlib.Path to some functions missed in Add support for pathlib for reading PEtab tables #93
  • Fix loading remote yaml files on Windows

Closes #80

@codecov-commenter
Copy link

codecov-commenter commented Nov 29, 2021

Codecov Report

Merging #91 (258bef9) into develop (1bd8e1d) will increase coverage by 0.02%.
The diff coverage is 96.66%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #91      +/-   ##
===========================================
+ Coverage    79.76%   79.79%   +0.02%     
===========================================
  Files           26       26              
  Lines         2941     2950       +9     
  Branches       713      714       +1     
===========================================
+ Hits          2346     2354       +8     
  Misses         421      421              
- Partials       174      175       +1     
Impacted Files Coverage Δ
petab/problem.py 65.92% <94.73%> (+1.44%) ⬆️
petab/core.py 87.02% <100.00%> (ø)
petab/visualize/data_overview.py 100.00% <100.00%> (ø)
petab/yaml.py 90.78% <100.00%> (ø)
petab/lint.py 78.14% <0.00%> (-0.60%) ⬇️
petab/simulate.py 81.13% <0.00%> (+1.88%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1bd8e1d...258bef9. Read the comment docs.

@dweindl dweindl requested a review from dilpath November 29, 2021 20:35
Copy link
Member

@dilpath dilpath left a comment

Choose a reason for hiding this comment

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

Thanks for the diligent work 👍 Feedback is minor and can be ignored if disagreed with.

petab/problem.py Outdated
Comment on lines 165 to 167
path_prefix = os.path.dirname(yaml_config)
get_path = lambda filename:\
f"{path_prefix}{os.sep}{filename}" # noqa: E731
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
path_prefix = os.path.dirname(yaml_config)
get_path = lambda filename:\
f"{path_prefix}{os.sep}{filename}" # noqa: E731
get_path = lambda filename: \
yaml_config.parent / filename # noqa: E731

petab/problem.py Outdated
Comment on lines 163 to 164
if isinstance(yaml_config, (str, Path)):
if isinstance(yaml_config, Path):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if isinstance(yaml_config, (str, Path)):
if isinstance(yaml_config, Path):
if isinstance(yaml_config, Path):

Then change else on line 168 to elif isinstance(yaml_config, str) and reduce indentation level by one for the block.

petab/problem.py Outdated
Comment on lines 169 to 176
# yaml_config may be path or URL
path_url = urlparse(yaml_config)
if not path_url.scheme or \
(path_url.scheme != 'file' and not path_url.netloc):
# a regular file path string
path_prefix = os.path.dirname(yaml_config)
get_path = lambda filename: \
f"{path_prefix}{os.sep}{filename}" # noqa: E731
Copy link
Member

Choose a reason for hiding this comment

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

Can the isinstance(..., Path) check above be removed and be handled by this same code (by changing the if condition here)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Could convert it to string and then handle it here. In the Path case, this will become unnecessarily complex, but would be shorter. Okay.

petab/problem.py Outdated
Comment on lines 178 to 188
# a URL
# extract parent path from
url_path = unquote(urlparse(yaml_config).path)
parent_path = str(PurePosixPath(url_path).parent)
path_prefix = urlunparse(
(path_url.scheme, path_url.netloc, parent_path,
path_url.params, path_url.query, path_url.fragment)
)
# need "/" on windows, not "\"
get_path = lambda filename: \
f"{path_prefix}/{filename}" # noqa: E731
Copy link
Member

Choose a reason for hiding this comment

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

All three of these code blocks for Path, str and URL seem quite similar, perhaps they can be combined converting them a type that supports the / operator then just define get_path once?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, this is unfortunately not possible, because we need different path separators. Thanks to Windows. The previous version was more concise, but didn't work on Windows...

petab/problem.py Outdated
Comment on lines 190 to 191
else:
path_prefix = ""
get_path = lambda filename: filename # noqa: E731
Copy link
Member

Choose a reason for hiding this comment

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

Can move out of else to before if, as the default

def create_report(
problem: petab.Problem,
model_name: str,
outdir: Union[str, Path] = ''
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
outdir: Union[str, Path] = ''
output_path: Union[str, Path] = '',

"""Create an HTML overview data / model overview report

Arguments:
problem: PEtab problem
model_name: Name of the model, used for file name for report
outdir: Output directory
"""

template_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
template_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)),
output_path = Path(output_path)
template_path = output_path.parent.absolute() / 'templates'

But then may need to use str(template_path) later

@@ -39,9 +46,9 @@ def create_report(problem: petab.Problem, model_name: str) -> None:
output_text = template.render(problem=problem, model_name=model_name,
data_per_observable=data_per_observable,
num_conditions=num_conditions)
with open(model_name + '.html', 'w') as html_file:
with open(Path(outdir) / f'{model_name}.html', 'w') as html_file:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
with open(Path(outdir) / f'{model_name}.html', 'w') as html_file:
with open(output_path / f'{model_name}.html', 'w') as html_file:

html_file.write(output_text)
copyfile(os.path.join(template_dir, 'mystyle.css'), 'mystyle.css')
copyfile(Path(template_dir, 'mystyle.css'), Path(outdir, 'mystyle.css'))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
copyfile(Path(template_dir, 'mystyle.css'), Path(outdir, 'mystyle.css'))
copyfile(template_path / 'mystyle.css', output_path / 'mystyle.css')

Comment on lines 82 to 85
def main(outdir: Union[Path, str] = None):
"""Data overview generation with example data from the repository for
testing
"""
Copy link
Member

Choose a reason for hiding this comment

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

Why is this test case code here and not in a test script?

Copy link
Member Author

Choose a reason for hiding this comment

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

🙈

@dweindl dweindl merged commit c3236cc into develop Nov 29, 2021
@dweindl dweindl deleted the ci_windows branch November 29, 2021 22:09
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

Successfully merging this pull request may close these issues.

3 participants