Ensures staged requirements include Agent Platform dependencies.
(requirements_txt_path: str)
| 38 | |
| 39 | |
| 40 | def _ensure_agent_engine_dependency(requirements_txt_path: str) -> None: |
| 41 | """Ensures staged requirements include Agent Platform dependencies.""" |
| 42 | if not os.path.exists(requirements_txt_path): |
| 43 | raise FileNotFoundError( |
| 44 | f'requirements.txt not found at: {requirements_txt_path}' |
| 45 | ) |
| 46 | |
| 47 | requirements = '' |
| 48 | with open(requirements_txt_path, 'r', encoding='utf-8') as f: |
| 49 | requirements = f.read() |
| 50 | |
| 51 | for line in requirements.splitlines(): |
| 52 | stripped = line.strip() |
| 53 | if ( |
| 54 | stripped |
| 55 | and not stripped.startswith('#') |
| 56 | and stripped.startswith('google-cloud-aiplatform') |
| 57 | ): |
| 58 | return |
| 59 | |
| 60 | with open(requirements_txt_path, 'a', encoding='utf-8') as f: |
| 61 | if requirements and not requirements.endswith('\n'): |
| 62 | f.write('\n') |
| 63 | f.write('google-cloud-aiplatform[agent_engines]\n') |
| 64 | f.write(f'google-adk[a2a]=={__version__}\n') |
| 65 | |
| 66 | |
| 67 | _DOCKERFILE_TEMPLATE: Final[str] = """ |