An opinionated package for integrating Gigantum and Overleaf Projects
Project description
gigaleaf
An opinionated library to link Gigantum Projects to Overleaf Projects. This tool automatically manages git repositories to link the outputs from a Gigantum Project to an Overleaf Project, letting you build a completely reproducible workflow from analysis to publication.
NOTE: This library is an early alpha proof of concept and subject to change!
NOTE: This library uses the Overleaf git bridge and is only included in paid Overleaf accounts. The Overleaf project owner must have a paid account, but collaborators do not.
Installation
gigaleaf may be installed using pip.
pip install gigaleaf
Usage
gigaleaf is currently designed to work inside Jupyter Notebooks running in Gigantum. The high-level API is pretty simple. The general workflow is:
-
Create an Overleaf Project
-
Get the git share URL from Overleaf
-
Click on "Git" under the sync options
-
Copy the URL only (not the entire git command) from the modal that is shown
-
-
Create an instance of gigaleaf
from gigaleaf import Gigaleaf gl = Gigaleaf()
This will start the configuration process where you enter the Overleaf URL along with the email and password you use to log into Overleaf. These will be stored in a file locally that is "untracked" in Gigantum and therefore will not sync or be shared. Other users will be prompted for their Overleaf credentials if they run your notebook. To be able to access your Overleaf project and run
gigaleaf
commands, they must also have access to your Overleaf project. -
Link an output file
gl.link_image('../output/fig1.png')
Here, you pass the relative path in Gigantum to the that file you want to link. Currently image and csv files are supported. Any time this file changes and you sync, it will automatically be updated in your Overleaf project! You only need to call this once per file that you wish to track. Calling it again will update settings (e.g. a figure caption)
-
Unlink an output file
gl.unlink_image('../output/fig1.png')
Remove a file from linking and delete its data from the Overleaf project.
-
Sync Projects
gl.sync()
This will pull changes from Overleaf, apply all gigaleaf managed changes, and then push back to Overleaf. Once files are linked, you typically will only be calling
.sync()
. It's safe to call.sync()
multiple times, in particular at the end of a notebook when you'd want to update Overleaf with your latest results.
Advanced Usage
gigaleaf
also provides Latex subfiles that you can use into your Overleaf Project that make adding and updating content
from Gigantum trivial. To take full advantage of this, the link methods have optional arguments:
.link_image()
- caption: A caption that will be added to the image. If omitted, not caption is inserted.
- label: A label to add to the figure for referencing inside your Overleaf document.
- width: A string to set width of the image. The default is "0.5\textwidth".
- alignment: A string to set the position of the image using the
adjustbox
package. The default is 'center'.
.link_csv()
- caption: A caption that will be added to the table. If omitted, not caption is inserted.
- label: A label to add to the table for referencing inside your Overleaf document.
.link_dataframe()
- kwargs: A dictionary of kwargs to pass directly into
pandas.DataFrame.to_latex
when generating the subfile When usinglink_dataframe()
,gigaleaf
assumes you've pickled your dataframe usingpandas.DataFrame.to_pickle
.
To use the subfiles generated you need to make a few modifications to your main.tex
preamble. You may need to modify
this depending on your exact project configuration:
% gigaleaf setup
\usepackage[export]{adjustbox} % Needed if linking image files
\usepackage{graphicx} % Needed if linking image files
\graphicspath{{gigantum/data/}{../data/}} % Needed if linking image files
\usepackage{csvsimple} % Needed if linking csv files
\usepackage{float} % Needed if linking csv files
\restylefloat{table} % Needed if linking csv files
\usepackage{booktabs} % Needed if linking dataframe files
\usepackage{subfiles} % Best loaded last in the preamble
% gigaleaf setup
Once configured, you can simply import the subfiles as they are created in your project. They will be named in a way that matches the files they are linked to:
\subfile{gigantum/subfiles/fig1_png}
In this example, this subfile would render the image fig1.png
that we linked above.
Contributing
This project is packaged using poetry. To develop, install packages with:
poetry install
When working, be sure to sign-off all of your commits.
If trying to install in a Gigantum Project from source for testing, poetry needs to not try to create a virtualenv and should install as the user. This can be done by setting the following options:
poetry config virtualenvs.create false
export PIP_USER=yes
Acknowledgements
Thanks to Simon Porter (@sjcporter) for valuable conversations and creating an early version of this concept in his "What does a university look like" project.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file gigaleaf-0.1.6.tar.gz
.
File metadata
- Download URL: gigaleaf-0.1.6.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.9 CPython/3.7.7 Linux/4.15.0-1067-aws
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a4dac50abafa3971585ad7496bfe2f45ef96327890a36d4c2838427f7ab7966 |
|
MD5 | 20cf3f29ad4e02a2adf6cd36be094c44 |
|
BLAKE2b-256 | 993c199ba57373846a7451625540157b7b08a922bc378a3d3f5ae494ecbf7f3c |
File details
Details for the file gigaleaf-0.1.6-py3-none-any.whl
.
File metadata
- Download URL: gigaleaf-0.1.6-py3-none-any.whl
- Upload date:
- Size: 22.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.9 CPython/3.7.7 Linux/4.15.0-1067-aws
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13d70a6e7c225fb3ef2c3c7019b416215e4db1bd4e18a7be681347b2aca8728a |
|
MD5 | 06363af2c8cdf4c4143c1ef7c72d3f59 |
|
BLAKE2b-256 | 6e1d68a0ba7ad4ccd07c71fcda92794fea4bb5bc1446bd86bef3cea981b611ee |