Skip to content

Add Manim Project Creating Subcommand #244

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

Closed
naveen521kk opened this issue Aug 4, 2020 · 21 comments · Fixed by #1418
Closed

Add Manim Project Creating Subcommand #244

naveen521kk opened this issue Aug 4, 2020 · 21 comments · Fixed by #1418
Assignees
Labels
good first issue Good for newcomers help wanted We would appreciate help on this issue/PR Suggestion Requesting a feature or change for Manim

Comments

@naveen521kk
Copy link
Member

naveen521kk commented Aug 4, 2020

How about a sub command for example, manim new project, which will create a folder with some scripts assets folder and also a config file. This would be helpful for new users and we can make the users use uniform folder structure. This would surely be helpful while debugging and the users can keep the projects organised and not like I usually do.
PS. I got the idea from chocolatey.

@leotrs
Copy link
Contributor

leotrs commented Aug 4, 2020

I like this idea. I'd suggest the command be manim init. What do you think this command should do? What directories should it create? How will the config file be generated? Etc. Let's flesh this out a bit more :)

@naveen521kk
Copy link
Member Author

├───assets
│   ├───codes
│   ├───images
│   └───sounds
├───logs
└───media
    ├───Tex
    ├───texts
    └───videos

This command should create should project structure. The config file can be generated as a copy of default.cfg and later the users can edit it using the command introduced by #212 . This need to be discussed a lot.

@leotrs
Copy link
Contributor

leotrs commented Aug 4, 2020

Yes, we'd have to discuss if we want to force/suggest a particular folder structure for the input files (what you called assets/). The output files (media/) are already enforced.

@Aathish04
Copy link
Member

we'd have to discuss if we want to force/suggest a particular folder structure for the input files

assets/ is already the places where Manim looks for images, audio files etc.

possible_paths = [
os.path.join(os.path.join("assets", "codes"), self.file_name),
self.file_name,
]

possible_paths = [
os.path.join(os.path.join("assets", "svg_images"), self.file_name),
os.path.join(os.path.join("assets", "svg_images"), self.file_name + ".svg"),
os.path.join(os.path.join("assets", "svg_images"), self.file_name + ".xdv"),
self.file_name,
]

default_dir=os.path.join("assets", "raster_images"),

default_dir=os.path.join("assets", "sounds"),

@leotrs
Copy link
Contributor

leotrs commented Aug 4, 2020

Oh? Ok in that case we should document that somewhere in the mythical quickstart guide.

In that case, I'm leaning toward making a quick-and-dirty manim init command!

@Aathish04
Copy link
Member

In that case, I'm leaning toward making a quick-and-dirty manim init command!

I just want to clarify that manim will search for assets from the current working directory, not from wherever the actual animation script is.

Before we implement manim init I think we should first ensure that manim also checks for the presence of assets folders next to the actual animation script and not just the cwd, like we are doing for the cfg file.

And like the cfg file, we could make the assets folder next to the file have the greatest priority, and the one in the cwd have the next greatest and so on.

@azarzadavila
Copy link
Contributor

I'd like to contribute to this if nobody is on it. So that it gives a first idea of what it could look like.

@Aathish04
Copy link
Member

I'd like to contribute to this if nobody is on it. So that it gives a first idea of what it could look like.

@azarzadavila
From my side, I'd just like to inform you that I'll be working on making it easier to add subcommands (adding notes, clearing up confusing code etc) and fixing some bugs in how subcommands are selected. I should take a PR doing this by this Sunday (I hope).

Please don't feel as if I'm restricting you, I'd just like to say that there will be a few changes to the code that will make it just a tiny bit easier to do this sort of stuff . You can still work on this in the meantime should you wish to.

@azarzadavila
Copy link
Contributor

I'd like to contribute to this if nobody is on it. So that it gives a first idea of what it could look like.

@azarzadavila
From my side, I'd just like to inform you that I'll be working on making it easier to add subcommands (adding notes, clearing up confusing code etc) and fixing some bugs in how subcommands are selected. I should take a PR doing this by this Sunday (I hope).

Please don't feel as if I'm restricting you, I'd just like to say that there will be a few changes to the code that will make it just a tiny bit easier to do this sort of stuff . You can still work on this in the meantime should you wish to.

@Aathish04
Ah okey great. There really is no rush so I think I'll wait.

@PgBiel PgBiel added the new feature Enhancement specifically adding a new feature (feature request should be used for issues instead) label Aug 8, 2020
@Aathish04
Copy link
Member

Ah okey great. There really is no rush so I think I'll wait.

@azarzadavila The PR I was talking about has been merged. You can implement manim init now!

@leotrs
Copy link
Contributor

leotrs commented Aug 23, 2020

@azarzadavila are you interested in implementing this? :)

@cobordism
Copy link
Member

Hi everyone,
I think this is a great idea.

A few thoughts:
You don't have to create the /media folder because
(a) manim will create it anyway when you compile the scene
(b) but the media directory will be created somewhere else entirely if the user supplies the --media-dir cli flag, or changes it in the .cfg file and the we'd be left with empty and unused directories here.

manim new project, which will create a folder with some scripts assets folder and also a config file

If we are going to generate a bunch of directories, then this is how we would do it.
If however we take a more lightweight approach and generate only a python file and a config file then we don't need to create an entire directory.
We could do something like: manim new name and generate a name.py file with scaffolding for a scene (also called name) and a name.cfg file, and nothing more.
It's quick. it's clean. We don't need to worry about assets subfolders or the order in which they are search.... and it is probably enough for almost all users almost all of the time. no?

@leotrs
Copy link
Contributor

leotrs commented Oct 13, 2020

I like the idea of keeping it short and to the point. Any more functionality sounds like we will hit a situation of diminishing returns. Especially because every new functionality will require new tests and more maintenance etc.

@behackl behackl added help wanted We would appreciate help on this issue/PR and removed need taker labels Nov 14, 2020
@jsonvillanueva
Copy link
Member

This should be implemented after #1013 is merged

@WampyCakes
Copy link
Contributor

I think that when this command is called it also ought to include on the first line of the generated script:

# Manim Community vX.Y.Z

If the user doesn't want it, they can just delete the line once and it'll never be there again. Otherwise, they now can look back at the script later and tell what version they used (or others can tell).

@jsonvillanueva jsonvillanueva added Suggestion Requesting a feature or change for Manim and removed new feature Enhancement specifically adding a new feature (feature request should be used for issues instead) labels Apr 17, 2021
@e4coder
Copy link
Contributor

e4coder commented Apr 23, 2021

Can I get assigned?
I have some ideas.

The 'project' subcommand will create a folder, a config file, and a main.py. I was thinking that in each manim project there has to be one python file that will import all scenes from within the project.

manim new project <name>

The 'scene' subcommand will create a new file with a new scene. this scene may automatically be imported in the main.py file as well as config.cfg file. I was also thinking of scene templates. where the user may give an additional argument naming the template that he wants to use or subcommand can prompt another input demanding the name of the template. if the user does not provide a name then the default template will be used for the new file generation.

manim new scene <filename> <scene_name>

if scene_name is not provided then filename will be used as the scene name

@e4coder
Copy link
Contributor

e4coder commented Apr 23, 2021

We can also implement a manim init command this command will be similar to new project command but manim init will prompt input for the project name.

@jsonvillanueva
Copy link
Member

Assigned you! ... although I'm not sure if this is actually a good first issue since we've recently transitioned from argparse to click, our GitHub Wiki on adding subcommands is out of date, and there's currently no replacement documentation on how to actually do this. Do message out here, or (preferably) on Discord if you run into any issues in creating the subcommand, or any of the logic for this.

@e4coder
Copy link
Contributor

e4coder commented Apr 23, 2021

Thank you! ill reach out if I get stuck anywhere.

@e4coder
Copy link
Contributor

e4coder commented Apr 26, 2021

Hey guys,

The code for these commands is about 200 lines.
I was thinking maybe I should add 1 command per PR. I think this will help in the review process.

@e4coder
Copy link
Contributor

e4coder commented Apr 28, 2021

I have opened up a pull request #1418

@behackl behackl linked a pull request Apr 28, 2021 that will close this issue
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted We would appreciate help on this issue/PR Suggestion Requesting a feature or change for Manim
Projects
None yet
Development

Successfully merging a pull request may close this issue.