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

Added option to save to full paths #45

Closed
wants to merge 3 commits into from
Closed

Conversation

menamerai
Copy link
Collaborator

Address issue #42

Added options to script to allow users to save to full path instead of the fixed static dir. Also modified the scripts/map_tokens.py file for consistency in scripts.

I noticed that the part to allow for this save option is similar across scripts. Should I make a general function for this?

@menamerai menamerai self-assigned this Feb 26, 2024
@menamerai menamerai linked an issue Feb 26, 2024 that may be closed by this pull request
@menamerai menamerai force-pushed the 42-static-dir-follow-ups branch from d0991a3 to 4e490ac Compare February 27, 2024 04:32
scripts/map_tokens.py Outdated Show resolved Hide resolved
else:
filepath = os.path.expandvars(args.output)
print(f"Outputting to path {filepath}")

with open(f"{filepath}", "wb") as f:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
with open(f"{filepath}", "wb") as f:
with open(filepath, "wb") as f:

filepath = STATIC_ASSETS_DIR.joinpath(args.output)
print(f"Outputting file {args.output} to path {filepath}")
else:
filepath = os.path.expandvars(args.output)
Copy link
Contributor

Choose a reason for hiding this comment

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

why?

Copy link
Collaborator

Choose a reason for hiding this comment

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

e.g. $HOME

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, sorry, think I misinterpreted this - you're asking "why" about the whole block, in which case the answer is "because that's the straightforward reading of the issue that I wrote". I should have just made the issue "use the path the user gives without any reference to the static dir" - so that's on me.

Copy link
Contributor

Choose a reason for hiding this comment

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

No, I was asking just about expandvars - I haven't seen this before

@@ -32,10 +33,14 @@ def main():
default="delphi-suite/delphi-llama2-100k",
required=False,
)
parser.add_argument(
"--output",
help="Output path name. Must include at least output file name.",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's either output path or output file name, not output path name. This is a bit weird though, because: what if I want to save in my current working directory? I'll just pass "myfilename.pkl" meaning "./myfilename.pkl" but it'll save in static dir.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I endorse both points.

On reflection, we should be writing to the static dir very rarely, and when we do it's reasonable to expect the user to move the files there and check them in. The main purpose of the static dir is to have a straightforward way to read.

So output paths should just use the path the user passes in the most straightforward way possible, without any reference to the static dir.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Earlier in the code, line 60-69, there is a section that writes down all_tokens_list.txt, which the script isn't giving the user a choice on where to load in the script argument. Should I leave the code as-is, letting the script saving this to static or give it the same treatment as the labelled token pickle by adding an extra argument?

image

Copy link
Collaborator

@jaidhyani jaidhyani left a comment

Choose a reason for hiding this comment

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

Looks broadly good. I agree with @jettjaniak's comments. I'm sorry about the extra hassle, which is my fault - I should have just written "cut references to any particular dir" as part of the issue.

@menamerai menamerai force-pushed the 42-static-dir-follow-ups branch from d447d11 to 20843c5 Compare February 27, 2024 22:41
@menamerai menamerai requested a review from jaidhyani February 27, 2024 22:55
@joshuawe
Copy link
Collaborator

Hey,
adding an command line argument where to store the token_labels is already included in #40

I would not endorse using the STATIC_ASSETS_DIR as output of the label_all_tokens.py script. The files in STATIC_ASSETS_DIR should shipped with the repository, and hence not custom created by the user. So I would option for a save path determined by command line argument. (Similar, to what Jai said).

Also, the first message of this PR states that scripts/map_tokens.py was modified, but I can only see changes in scripts/label_all_tokens.py.

All in all I am not sure, if this PR will now fix any issue not part of #40 ? :/

@menamerai
Copy link
Collaborator Author

Hey @joshuawe. Yes scripts/map_tokens.py was modified, but we have decided to leave the file be, as it would conflict with Victor's work, and we don't need to save the result there locally anyways.

Also, yes I agree that a command line argument to choose the save path would be great, but if it is already included in #40, then I don't think that this PR is very productive. @jaidhyani do you think I should close this PR, or is there something different you had in mind that I could work towards?

@menamerai menamerai closed this Mar 7, 2024
@jettjaniak jettjaniak deleted the 42-static-dir-follow-ups branch May 22, 2024 10:05
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.

Static dir follow-ups
4 participants