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 macro for activating parent git repo environment #396

Closed
wants to merge 1 commit into from
Closed

Adding macro for activating parent git repo environment #396

wants to merge 1 commit into from

Conversation

cadojo
Copy link

@cadojo cadojo commented Sep 9, 2020

This is a macro for code I use at the top of my notebooks. It searches for a Git repository in a directory above the notebook working directory. If one is found, then it runs Pkg.activate on that top-level path.

It partially addresses one non-default Pluto use case - storing notebooks in Git repositories. This has been discussed in [#142].

The usage is simply @activate_repo_env.

Despite Pluto not fully understanding macros (#196), I think this macro should work. It doesn't use any outside variables, and all variables in the macro are locally scoped within a let block.

I don't think this is an ideal fix - maybe a better solution would be to add arguments for SVN, Git, or the current working directory? Or maybe switch this from a macro to a function, or put it in a Pluto.run argument?

* @activate_repo_env checks for a parent Git repo. If one is
  found, then it runs Pkg.activate() on that top level path.
@Roger-luo
Copy link
Contributor

I feel this might not necessary to be in the frontend but can just serve as an option when one runs Pluto.run?

@cadojo
Copy link
Author

cadojo commented Sep 9, 2020

I feel this might not necessary to be in the frontend but can just serve as an option when one runs Pluto.run?

I agree that could work too. One thought I had against that was the case where you're running multiple Pluto notebooks off of one server. If you're running two notebooks that don't use the same environment, then you'd need to run multiple server instances, right?

Either way, I agree the front end isn't the best place for this. The best case scenario is each notebook using its own workspace, so the environment is entirely contained in the notebook.

@fonsp
Copy link
Owner

fonsp commented Sep 9, 2020

This should not be part of Pluto - it should be a small code snippet that you share with others.

Adding syntax to every notebook is a very serious decision that cannot be reversed without breaking old notebooks. We should avoid it whenever possible.

In this case, we will want to remove this macro in a couple of months when #142 is fixed.

@fonsp
Copy link
Owner

fonsp commented Sep 9, 2020

But @Roger-luo it sounds like the requested feature is to run your notebook with julia --project. We support this, right? Since we use nothing instead of ""?

@fonsp fonsp closed this Sep 9, 2020
@Roger-luo
Copy link
Contributor

If you're running two notebooks that don't use the same environment, then you'd need to run multiple server instances, right?

No, we have per notebook environment now. You can specify an environment for each notebook directly, it's a PR just get merged #341

A more convenient interface is implemented in https://github.com/fonsp/PlutoUtils.jl/pull/9/files#diff-0df7c7b3a0fa9ac7a22c08596327a096R23 if you are familiar with CLIs.

You can choose to start pluto manually with that command, or just use the same code to do it.

@cadojo cadojo deleted the 142-git-env branch September 9, 2020 19:21
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.

3 participants