# Tasks: Projects & Env Import

> Submit multi-file Python project folders or .zip archives to Serverless Tasks, configure entrypoints and requirements, and bulk-import environment variables from .env, shell, JSON, YAML, or TOML files.

Source: https://docs.meshive.ai/serverless/tasks/projects/

Run full multi-file Python repositories and bulk-import environment variables in [Serverless Tasks](/serverless/tasks/).

## Run a project

A single file is enough for many jobs. When your code is a folder — several modules, config files, a training repo — switch the **Script** card to **Project** and run it as it is, instead of pasting everything into one file.

### Add a project

Drop a project folder or a `.zip` on the Script card, or click **Choose folder** or **Choose .zip**. A GitHub **Download ZIP** works as it is: the top-level folder inside it becomes the project name.

- **One asset, uploaded for you.** The console uploads the project to [Assets](/assets/) as one asset and attaches it to the task as an input, so it counts toward the [20-input limit](/serverless/tasks/#limits). The upload starts as soon as you drop, while you fill in the rest of the form.
- **Submit waits for the upload.** **Submit task** stays off until the upload has finished — it doesn't submit by itself, so click it again afterward. If the upload fails, **Retry** is on the project row.
- **It stays in Assets.** The project is an ordinary asset in managed storage, [billed as storage](/assets/billing/) like any other upload until you delete it. Dropping the same folder again uploads another copy (`-2`, `-3`, and so on).
- **Replace or Remove** on the project row swaps or drops it. Switching between **Script** and **Project** keeps what you entered in both.

**What the console leaves out.** It tells you what it skipped under the project row, for example `Skipped .git, __pycache__ (1,204 files)`.

| Left out | Why |
| --- | --- |
| Version control, caches and tool folders — `.git` (and `.hg`, `.svn`), `__pycache__` and `*.pyc`, `node_modules`, `.ipynb_checkpoints`, `.mypy_cache`, `.pytest_cache`, `.ruff_cache`, `.tox`, `.nox`, `.idea`, `.vscode`, `*.egg-info` | Rebuilt or irrelevant at run time, and often thousands of files |
| Virtual environments — `.venv`, `venv`, and any folder that contains a `pyvenv.cfg`, whatever its name | Install packages with a requirements file instead |
| Experiment logs — `wandb`, `mlruns`, `lightning_logs` | Output, not code |
| Operating-system leftovers — `.DS_Store`, `__MACOSX`, `._*`, `Thumbs.db`, `desktop.ini` | Noise |
| `.env` and `.env.*` files (but not `.env.example` and the like) | Assets aren't encrypted and are visible in Assets, so secrets stay out. The console offers to load them into **Environment & secrets** instead — see below |
| Empty files, except empty `.py` files such as `__init__.py` (and `py.typed`, `.gitkeep`) | Assets can't hold empty files; an empty `__init__.py` is kept because it makes a folder a package |

Other folders — `data`, `build`, `dist`, `env` — are uploaded like any other, so keep large datasets out of the project and attach them as [input assets](/assets/using/#task-inputs).

**A `.env` file in the project.** The console doesn't upload it. Under the project row, **Load into Environment & secrets** reads it into the rows of that card (with several `.env` files, there is one **Load** button for each) and tells you where the variables went. Because the variables are then set in the container, code that calls `python-dotenv`'s `load_dotenv()` keeps working without the file.

**File count.** A task can fetch about 500 files in total at run time, counting the project and the files of the input assets you attach. Linked sources (Hugging Face, CivitAI, URLs) and bucket references aren't counted. Over the limit, the console names the three folders with the most files and offers a **Skip** button for each. Many small files are better packed into one archive that your program unpacks.

**A `.zip` is unpacked in your browser.** One that is password-protected, uses non-UTF-8 file names, or unpacks to more than about 2 GiB can't be opened that way — unzip it and drop the folder instead.

### Choose what runs

Once the project is on the card, set:

- **Run** — the `.py` file to execute. The console picks a top-level `main.py`, `train.py`, `run.py` or `__main__.py` for you, the only candidate left once files like `setup.py`, `conftest.py` and `test_*.py` are set aside, or the only file with one of those names anywhere in the project (such as `mypkg/train.py`). When it can't tell, the field is empty and the form asks you to **Choose the file to run**.
- **Install requirements from** — a `requirements*.txt` in the project. A top-level `requirements.txt` is chosen by default; choose **None** to skip installing.
- **Extra packages (optional)** — `requirements.txt` lines installed *before* the project's own requirements file, for a package you don't want to add to the repository.
- **Arguments (optional)** — passed to the file as command-line arguments.

Under these fields the console shows the exact commands that will run, such as `pip install -r requirements.txt` followed by `python -m mypkg.train`. The Run summary's **Entrypoint** row shows the same command.

### How a project runs

The project is downloaded like any input asset — that [download time is billed](/serverless/tasks-billing/#how-billing-works) — and then:

1. **It's copied into a working folder**, so the program can write next to its code. Very large files (~64 MiB and up) are linked read-only instead of copied, so big weights inside a project aren't stored twice; they can be read but not changed in place.
2. **The working directory is the project folder**, so relative paths such as `data/train.csv` or `configs/base.yaml` work, and sibling modules import as usual. This differs from Script mode, where the working directory is `/outputs`.
3. **Requirements are installed.** Extra packages first, then `pip install -r <file>` from the project folder. Install time is billed, and a failed install ends the task as a user fault — see [requirements.txt](/serverless/tasks/#requirementstxt).
4. **The entry file runs** as `python path/to/file.py`. When the file sits in a package — every folder from the project root down to it has an `__init__.py` — it runs as `python -m pkg.module` instead, so relative imports such as `from .utils import load` work, and sibling modules imported by plain name (`import utils`) are still found. A file at the top level always runs as a plain script, and `__init__.py` can't be chosen — add a `__main__.py` to run a package. If your code starts Python again itself with `python -m` (some multi-GPU launchers do), import sibling modules through the package (`from pkg import utils`) in those processes.
5. **New and changed files are collected.** When the program exits, files it created or changed inside the project folder are moved to `/outputs` at the same relative path and uploaded with the rest of the [outputs](/serverless/tasks/outputs/#writing-your-script-outputs). If moving them would pass the [output file limit](/serverless/tasks/outputs/#over-the-file-limit), files in shallower folders are moved first until `/outputs` reaches the limit, and the log lists the ones that weren't saved.

> **Caution — Stopped and timed-out runs:**
> If you **Stop** a task or it hits its max run time, the move in step 5 isn't guaranteed — only files the program already wrote to `/outputs` directly are kept. For long runs, write checkpoints and results to `/outputs`.

### Re-run and the task page

The task page shows the project instead of the code: its name with **Open in Assets**, the command, and the requirements file. **Re-run with same config** (and **Re-run** on the task list) attaches the same project and input assets again, after checking they still exist.

The project isn't uploaded again, so edits on your computer aren't picked up — drop the folder again to run the new version. If the project asset has been deleted since, the form says so and asks you to drop the folder again.

## Import environment variables

Instead of typing each row in **Environment & secrets**, bring in a whole set of variables:

- **Paste into a name field.** Paste `KEY=VALUE` lines, JSON or YAML into the name of a row and it expands into one row per variable.
- **Paste into a value field.** Paste a block of several `KEY=VALUE` lines. A single-line value is never split, so a value that contains `=`, like a base64 string or a URL, stays as you typed it.
- **Drop a file.** Drop a file anywhere on the card.
- **Click Import from file** and choose a file (up to 1 MiB).

A line under the card sums up the result, for example "Imported 5 variables · 1 replaced · 2 marked secret · 1 line skipped".

- **Existing names are replaced.** A name that is already a row gets the new value; the other names are added as new rows. If a name appears twice in the pasted text, the last one wins.
- **Secret-looking names come in as Secret.** A name containing `TOKEN` (as a whole word, so `MAX_TOKENS` is left alone), `SECRET`, `PASSWORD`, `API_KEY`, `ACCESS_KEY`, `PRIVATE_KEY` or `CREDENTIAL` is imported as a **Secret**. It's a guess from the name only: click the **Variable** or **Secret** pill on a row to change it.
- **Values come in as written.** Wrapping quotes are removed, but `${VAR}`, `$(command)` and `%VAR%` are not expanded. Numbers and booleans become text.
- **A file with several sets of variables asks which one you want.** Two Compose services or two Kubernetes containers are never merged silently: pick one, or **All**, where a name that appears twice takes the later value.
- **Kubernetes secrets are decoded.** Values under `data` are decoded from base64 and come in as secrets, along with `stringData`. `valueFrom` entries have no value to import, so they're skipped.

The format is recognized from the content, so the file name doesn't matter:

| Format | What's understood |
| --- | --- |
| `.env` | `KEY=value`, `KEY: value`, `# comments`, `"double"` quotes with `\n` escapes and multi-line values, `'single'` quotes |
| Shell | `export KEY=value` (several on a line), `.envrc`, fish `set -x`, csh `setenv` |
| Windows | PowerShell `$env:KEY = "value"`, `set KEY=value`, `set "KEY=value"`, `setx` |
| JSON | An object, a list of `{"name": …, "value": …}` or `"KEY=value"` strings, comments and trailing commas (`launch.json`), AWS SAM `env.json`, ECS task definitions |
| YAML | Plain maps, Docker Compose, Kubernetes `env`, ConfigMaps and Secrets, GitHub Actions `env`, `serverless.yml`, App Engine `env_variables` |
| TOML | `wrangler.toml`, `fly.toml`, `netlify.toml`, Cargo `[env]`, mise |
| Other | Java `.properties`, INI, systemd `Environment=`, Dockerfile `ENV`, two columns pasted from a spreadsheet |

- **Lines that aren't valid variable names are skipped** and counted. The usual limits and reserved names still apply.

The same import works in a Pod's or template's **Environment variables** section: names that match a variable the template already defines fill in its value, and names that look secret are added as secret variables.
