-
Notifications
You must be signed in to change notification settings - Fork 29
Script to create new projects #19
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
Conversation
|
Thanks @Ricocotam, it's much needed! However, we need a way to avoid putting executable code into a string such as this I would suggest creating template python files in the bootstrap directory, copying them and even replacing some elements in it. For instance, instead of this, we would have the following file in import torch.nn as nn
class MyNetwork(nn.Module):
def __init__(self, *args, **kwargs):
super(MyNetwork, self).__init__()
# Assign args
def forward(self, x):
# x is a dictionnary given by Dataset class
pred = self.net(x)
return pred # This is a tensor (or several tensors)Also, we discussed with @MicaelCarvalho. With the following class names: As well as other files such as Lastly, files from Do you agree? Is it clear? @Ricocotam |
|
Alright, so I did what you said on the latest commit |
bootstrap/new.py
Outdated
|
|
||
|
|
||
| parser = ArgumentParser() | ||
| parser.add_argument("project_path", action="store", type=str, help="Path to new project") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to keep project_path.
What do you think @MicaelCarvalho ?
| new_dir = path / directory | ||
| if directory != "models": | ||
| new_dir.mkdir() | ||
| files = get_files(new_dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As specified here, we would like to follow this path pattern bootstrap/templates/default/project/datasets/dataset.py instead of your current bootstrap/template/datasets/template_dataset.py.
| def factory(engine=None, mode="train"): | ||
| opt = Options()['model.metric'] | ||
|
|
||
| if opt['name'] == '{PROJECT_NAME_LOWER}metric': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'metric' can be removed here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure to understand what you mean ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def factory(engine=None, mode="train"):
opt = Options()['model.metric']
if opt['name'] == '{PROJECT_NAME_LOWER}':| opt = Options()['model.metric'] | ||
|
|
||
| if opt['name'] == '{PROJECT_NAME_LOWER}metric': | ||
| metric = {PROJECT_NAME_LOWER}metric() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metric
|
Thanks! @Ricocotam We should probably add a test to verify that everything can work. |
|
I'll fix your different comments soon. Anything to add ? |
|
So we need some tests now The only thing I didn't do is to name custom dataset after the project name, I kept I can write some tests (we just have to check files have the right content and that they are created) but I know how it works already. May be, to ensure code is both clear and that agree on what/how it does it, someone else should right the tests |
Script to create new projects v2 (old in PR #19)
|
Solved in #35 |
From issue #17 I created a minimal example of what I had in mind. This is a minimal example and some questions need to be answered.
Path of the new project
We need to create a folder for the project. I propose to use 2 different name : project_path and project_name. We then could have an architecture like :
(
+denotes a folder,-a file)This is an open suggestion. I choose this implementation so logs' folder is also created and is with the rest of the code.
Network as minimal example
I did a minimal example so we can discuss implementation details. Creating files and folders is done with
pathlib.Pathto use the/operation to join paths. The real question is : how to we fill created files with basic content ? I choose to have raw text written in thenew.pyI am Pull Requesting but I don't think that's the better option as this is not easily maintainable and it leads to a really longnew.pyfile. My suggestion is to have a basic file we can copy to the project created. This requires to store quite a lot of files in the lib only used to be copied so it has some drawbacks too.I am also working on a complete project creation with options to create any relevant directory but I didn't want to pollute the discussion with useless lines of code