Opened 2 years ago

Closed 2 years ago

#30452 closed enhancement (fixed)

"sage -startuptime" should accept file names too

Reported by: Matthias Köppe Owned by:
Priority: major Milestone: sage-9.2
Component: doctest framework Keywords:
Cc: Dima Pasechnik, Tobias Diez, Frédéric Chapoton, John Palmieri, Travis Scrimshaw, Volker Braun Merged in:
Authors: Matthias Koeppe Reviewers: John Palmieri
Report Upstream: N/A Work issues:
Branch: 306c390 (Commits, GitHub, GitLab) Commit: 306c390c8dedc5763fde5b94fa4f8e915e27ba46
Dependencies: Stopgaps:

Status badges

Description (last modified by Matthias Köppe)

(from #30410)

This is so that all of the tox environments (#30410, #30408) can be run on files and directories.

Example:

$ ./sage -startuptime src/sage/tensor/ src/sage/geometry/polyhedron/base.py

Change History (15)

comment:1 Changed 2 years ago by Matthias Köppe

Branch: u/mkoeppe/_sage__startuptime__should_accept_file_names_too

comment:2 Changed 2 years ago by Matthias Köppe

Authors: Matthias Koeppe
Commit: 06c4b55d488d11399a83143b7942aa56e796884b
Description: modified (diff)
Status: newneeds_review

New commits:

06c4b55src/bin/sage-startuptime.py: Accept file/directory names too

comment:3 Changed 2 years ago by Matthias Köppe

Cc: Travis Scrimshaw added

comment:4 Changed 2 years ago by Matthias Köppe

Cc: Volker Braun added
Description: modified (diff)

comment:5 Changed 2 years ago by John Palmieri

It's certainly true that ./sage --startuptime src/sage/homology/simplicial_set.py raises an error without this branch and doesn't raise an error with it, but with this branch it produces no output. What is it supposed to do?

By the way, it makes me a little uncomfortable to use the same loop variable twice like this:

for module_arg in cmdline_args:
    ...
    for module_arg in matching_modules:
        ...

comment:6 Changed 2 years ago by John Palmieri

On the other hand, ./sage -startuptime src/sage/geometry/polyhedron/base.py does produce output. I'm confused.

comment:7 Changed 2 years ago by John Palmieri

I would also recommend an explicit import os statement. I'm not sure why the script works without it. Edit: I guess it's being imported from sage.all, but it would be better to make it explicit at the top.

Last edited 2 years ago by John Palmieri (previous) (diff)

comment:8 Changed 2 years ago by Matthias Köppe

Without this ticket ./sage --startuptime sage.homology.simplicial_set gives

[]
Traceback (most recent call last):
  File "/Users/mkoeppe/s/sage/sage-rebasing/worktree-algebraic-2018-spring/src/bin/sage-startuptime.py", line 148, in <module>
    raise ValueError('"' + module_arg + '" does not uniquely determine Sage module.')
ValueError: "sage.homology.simplicial_set" does not uniquely determine Sage module.

Before working on this ticket, I had never used these scripts. I don't really know whether the above is expected, or a result of undetected bitrot over the years.

I think that it only works for modules that are loaded when sage.all is loaded.

comment:9 Changed 2 years ago by John Palmieri

Is it worth printing a message if the file or module is not loaded when sage.all is loaded, rather than being completely silent?

comment:10 Changed 2 years ago by git

Commit: 06c4b55d488d11399a83143b7942aa56e796884b4256c9f28934368161c672162c397cd34dbcbd93

Branch pushed to git repo; I updated commit sha1. New commits:

25e1c5fsrc/bin/sage-startuptime.py: import os
4256c9fsrc/bin/sage-startuptime.py: Both with file and module argument, warn if there is no matching module; non-uniqueness is not an error

comment:11 Changed 2 years ago by git

Commit: 4256c9f28934368161c672162c397cd34dbcbd93306c390c8dedc5763fde5b94fa4f8e915e27ba46

Branch pushed to git repo; I updated commit sha1. New commits:

306c390src/bin/sage-startuptime.py: Use different variable in nested loop

comment:12 Changed 2 years ago by Matthias Köppe

How about this version?

comment:13 Changed 2 years ago by John Palmieri

Reviewers: John Palmieri
Status: needs_reviewpositive_review

Great, thank you for the changes.

comment:14 Changed 2 years ago by Matthias Köppe

Thanks!

comment:15 Changed 2 years ago by Volker Braun

Branch: u/mkoeppe/_sage__startuptime__should_accept_file_names_too306c390c8dedc5763fde5b94fa4f8e915e27ba46
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.