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

Adding date-time to frames filename #454

Merged
merged 4 commits into from
Sep 23, 2021
Merged

Adding date-time to frames filename #454

merged 4 commits into from
Sep 23, 2021

Conversation

gurnarok
Copy link
Contributor

@gurnarok gurnarok commented Sep 6, 2021

Working with a problem, creating multiple TF frames to see, what has changed and not noticing to make a copy of the file, overwriting a previous data.

With this, adding -d or --datetime as an argument on the run command, it adds a date-time stamp to the end of the file.

Originally I used this on ros1, then instructed to make for future versions.

Copy link
Member

@aprotyas aprotyas left a comment

Choose a reason for hiding this comment

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

The changes LGTM but I believe the style guide prefers "single quotes over double quotes as long as no escaping is necessary".

@gurnarok
Copy link
Contributor Author

gurnarok commented Sep 7, 2021

The changes LGTM but I believe the style guide prefers "single quotes over double quotes as long as no escaping is necessary".

Thank you for the feedback. Fixed the issue :)

Copy link
Member

@aprotyas aprotyas left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Contributor

@clalancette clalancette 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 PR!

I have a few thoughts about this:

  1. I think that we should change this to add the date by default. That way if users run it without any arguments, they won't lose data.
  2. I think we should also provide a -o option so that users can control the filename if they really want to have a "stable" filename.
  3. I don't think using %Y-%m-%d_%H.%M is actually good enough. What happens if a user runs the same command multiple times in a minute? I think we need to add seconds to this to make it safer.

Comment on lines 91 to 93
datetime = time.strftime('%Y-%m-%d_%H.%M.%S')
frames_gv = '{:s}_{:s}.gv'.format(parsed_args.output, datetime)
frames_pdf = '{:s}_{:s}.pdf'.format(parsed_args.output, datetime)
Copy link
Contributor

Choose a reason for hiding this comment

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

Almost. If the user specifies a filename, I think that we should honor it exactly without further changes. So this should be:

frames_gv = '{:s}.gv'.format(parsed_args.output)
framed_pdf = '{:s}.pdf'.format(parsed_args.output)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I was trying to be fancy with adding a timedstamp to it, if the user runs the same command multiple times with same filename.

Copy link
Member

@aprotyas aprotyas Sep 23, 2021

Choose a reason for hiding this comment

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

Ok, I was trying to be fancy with adding a timedstamp to it, if the user runs the same command multiple times with same filename.

Hmm, that's a valid concern, but also the user should shoulder such a burden.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, agreed. My basic thinking on this is that by default, we should be sure not to overwrite data. But if the user explicitly tells us to overwrite something, we should just go ahead and do it.

@clalancette
Copy link
Contributor

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@clalancette clalancette merged commit 8e508d0 into ros2:ros2 Sep 23, 2021
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.

None yet

3 participants