Skip to content

Commit

Permalink
Merge pull request #6 from maxisoft/dev
Browse files Browse the repository at this point in the history
Enhance Backup Automation and Documentation
  • Loading branch information
maxisoft authored Jul 27, 2024
2 parents d22c0d1 + 44f8148 commit caa9e8e
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/doit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ on:
branches: [ "main" ]
schedule:
- cron: "33 18 * * *"
workflow_dispatch:

env:
PYTHON_VERSION: "graalpy-24"
PYTHON_VERSION: "3.11"

permissions:
contents: read
Expand All @@ -29,6 +30,7 @@ jobs:
python-version: "${{ env.PYTHON_VERSION }}"

- name: Cache pip dependencies
if: ${{ !startsWith('graal', env.PYTHON_VERSION) && github.actor == github.repository_owner }}
uses: actions/cache@v4
with:
path: ~/.cache/pip
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ name: pull request lint and test

on:
pull_request:
workflow_dispatch:

env:
PYTHON_VERSION: "graalpy-24"
PYTHON_VERSION: "3.11"

permissions:
contents: read
Expand All @@ -26,7 +27,7 @@ jobs:
python-version: "${{ env.PYTHON_VERSION }}"

- name: Cache pip dependencies
if: ${{ github.actor == github.repository_owner }}
if: ${{ !startsWith('graal', env.PYTHON_VERSION) && github.actor == github.repository_owner }}
uses: actions/cache@v4
with:
path: ~/.cache/pip
Expand Down
69 changes: 69 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
## Kaggle Notebook Backup 📚

This Python script automates downloading your Kaggle notebooks, including private ones (if desired), and creates a compressed archive for easy backup or transfer.

### **Local Installation:**

1. **Prerequisites:**
- Python 3.x
- `kaggle` and other packages: Install with `pip install -r requirements.txt`
- Set up the Kaggle CLI according to the [official documentation](https://www.kaggle.com/docs/api)
2. **Download the repo:**

```bash
git clone https://github.com/maxisoft/kaggle-notebook-backup.git
```

3. **Run the script:**

```bash
python main.py [OPTIONS]
```

#### Options:

* `-o, --output` (default: `./kernels.zip`): Name and location of the output archive.
* `-p, --include-private` (default: `True`): Include private notebooks in the backup.
* `-u, --user` (default: `current user`): Kaggle username whose notebooks to download.
* `-t, --tmp-dir` (default: `temporary directory`): Path to a custom temporary directory.

#### Default Behavior:

The default execution will create an archive named `kernels.zip` with all your Kaggle kernels in the *current directory*.

### Running via GitHub Actions Workflow 🚀

This repository also includes a GitHub Actions workflow named `doit.yml` that can be used to automate the script execution on a schedule or upon pushes to the `main` branch.
To enable this functionality, you'll need to configure secrets within your repository settings.
**Here's a breakdown of the steps involved:**

1. **Fork this Repository:** Create your own fork of this repository on GitHub.
2. **Navigate to Actions:** Go to your forked repository's settings and then to the "Actions" tab.
3. **Enable the `doit.yml` Workflow:** Find the `doit.yml` workflow and enable it to run on pushes or schedules.
4. **Set Up Secrets (Required):**
- Navigate to your repository's settings and then to "Secrets."
- Create two secrets:
- `KAGGLE_USERNAME`: Your Kaggle username.
- `KAGGLE_KEY`: Your Kaggle API key (obtainable from your profile settings).
5. **Manual Trigger:**
You can manually trigger the workflow by navigating to the “Actions” tab in your repository, selecting the `doit.yml` workflow, and clicking the “Run workflow” button.
6. **Output as GitHub Artifact:**
- The resulting zip file (`kernels.zip`) will be uploaded as a GitHub artifact, making it easy to download and access from the Actions tab.

**Important Note:**

- **Security:** Never store your API key directly in the code. Using GitHub secrets ensures secure handling of sensitive information.

**Benefits of Using GitHub Actions:**

- **Automated Execution:** The script runs automatically based on your chosen schedule, upon code pushes, or manually.
- **Regular Backups:** Scheduled execution helps maintain updated backups of your notebooks.
- **Reduced Manual Work:** Frees you from manually running the script, saving time and effort.

By following these steps and leveraging GitHub Actions, you can automate the process of backing up your Kaggle notebooks, ensuring a more streamlined and safe workflow.

### Contributing:

Feel free to contribute bug fixes, improvements, or feature requests. Fork the repository, create a pull request, and share your changes! 🚀

0 comments on commit caa9e8e

Please sign in to comment.