Skip to content

Add CLI Command to Check Deployment Prerequisites #1

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

Merged
merged 30 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
74168e3
First commit
BenCodeOcean Mar 25, 2025
bf89674
Refactor project structure: rename to co-support, update requirements…
BenCodeOcean Mar 26, 2025
46aa399
Add __init__.py to prerequisites module
BenCodeOcean Mar 26, 2025
4952630
Add __init__.py files to checks and core modules
BenCodeOcean Mar 26, 2025
1968a92
Update README.md: enhance installation instructions and usage examples
BenCodeOcean Mar 26, 2025
09292fd
Rename run_checks to check_prerequisites for clarity and update refer…
BenCodeOcean Mar 26, 2025
5da5458
short url
BenCodeOcean Mar 30, 2025
a33dd9d
syle fixes
BenCodeOcean Mar 30, 2025
95a6c78
style fixes
BenCodeOcean Mar 30, 2025
c5e4e3f
role arn
BenCodeOcean Mar 30, 2025
9d3def6
Improve clarity in vCPU and EIP quota checks by enhancing return mess…
BenCodeOcean Mar 30, 2025
745021d
Update README and code to include role option and improve messaging f…
BenCodeOcean Mar 30, 2025
b262eab
Refactor argument parsing and enhance YAML handling; improve help mes…
BenCodeOcean Apr 2, 2025
b86ef3d
Enhance .gitignore for macOS, Linux, and Windows system files; improv…
BenCodeOcean Apr 3, 2025
9330bdc
Update README and code to rename 'hosted-zone' to 'zone'; enhance rol…
BenCodeOcean Apr 3, 2025
8cbf069
Copilot review
BenCodeOcean Apr 3, 2025
9ebcb71
Zvika review part 1
BenCodeOcean May 4, 2025
edc7fda
Zvika review part 2
BenCodeOcean May 6, 2025
e2ba338
Compute Environments quota and more
BenCodeOcean May 7, 2025
c7606d0
comment added
BenCodeOcean May 7, 2025
6284d51
Refactor environment handling and access checks for improved clarity …
BenCodeOcean May 7, 2025
1ff663c
Zvika review part 3
BenCodeOcean May 8, 2025
6f2bf1d
Refactor answer handling and question prompting for improved readabil…
BenCodeOcean May 8, 2025
8e3430a
Fix typos in class names and instance descriptions for improved clarity
BenCodeOcean May 8, 2025
589c789
Zvika review
BenCodeOcean May 19, 2025
6f7051e
src folder
BenCodeOcean May 19, 2025
2e71afe
Add project scripts section and correct ExistingVpcCheck name
BenCodeOcean May 21, 2025
46c5b94
Refactor ask methods in Question and YesNoQuestion classes for improv…
BenCodeOcean May 21, 2025
cea73f8
support older python version
BenCodeOcean May 21, 2025
c2fb026
Update installation command to force reinstall package
BenCodeOcean May 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 148 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# macOS system files
.DS_Store
.AppleDouble
.LSOverride

# Thumbnails
._*

# Files that might appear on external disks
.Spotlight-V100
.Trashes

# Linux system files
*~
.nfs*

# Windows system files
Thumbs.db
ehthumbs.db
Desktop.ini
$RECYCLE.BIN/

# Python bytecode
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
venv/
ENV/
env.bak/
venv.bak/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyderworkspace

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# Hatchling build artifacts
*.dist-info/
*.egg-info/
65 changes: 63 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,63 @@
# co-assistant
Code Ocean Command-Line Assistant
# Code Ocean Support Command-Line

## Installation

### pip
To install or upgrade the co-support, run the following command:
```bash
pip install --force-reinstall git+https://github.com/codeocean/co-support.git
```

### virtualenv
To install for development purposes using a virtual environment:
```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
```

## Usage
```bash
usage: co-support check-prerequisites [-h] [-s | --silent | --no-silent] [-f {table,yaml}] [-o OUTPUT] [--version VERSION] [--role ROLE] [--domain DOMAIN] [--zone HOSTED_ZONE] [--cert CERT]
[--private-ca | --no-private-ca] [--vpc VPC] [--internet-facing | --no-internet-facing]

options:
-h, --help show this help message and exit
-s, --silent, --no-silent
Run the script in silent mode (default: False)
-f, --format {table,yaml}
Output format: table or yaml (default: table)
-o, --output OUTPUT Path to the directory where the output file will be saved (default: None)
--version VERSION Version of Code Ocean to deploy (e.g., v3.4.1) (default: None)
--role ROLE ARN of the IAM role to deploy the Code Ocean template (e.g., arn:aws:iam::account-id:role/role-name) (default: None)
--domain DOMAIN Domain for the deployment (e.g., codeocean.company.com) (default: None)
--zone HOSTED_ZONE
Hosted zone ID for the deployment (e.g., Z3P5QSUBK4POTI) (default: None)
--cert CERT ARN of the SSL/TLS certificate (e.g., arn:aws:acm:region:account:certificate/certificate-id) (default: None)
--private-ca, --no-private-ca
Indicate if the certificate is signed by a private CA (default: False)
--vpc VPC ID of the existing VPC (e.g., vpc-0bb1c79de3fd22e7d) (default: None)
--internet-facing, --no-internet-facing
Indicate if the deployment is internet-facing (default: True)
```

### Interactive Example
```bash
co-support check-prerequisites
```

### Silent Example
```bash
co-support check-prerequisites -s \
--version v3.4.1 \
--internet-facing \
--domain codeocean.acmecorp.com \
--zone A0B1C2D3E4F5G6H7I8J9 \
--cert arn:aws:acm:us-east-1:000000000000:certificate/01234567-890a-bcde-f012-3456789000 \
--vpc vpc-0123456789abcdeff \
--role arn:aws:iam::000000000000:role/Administrator
--private-ca \
```

## Notes
Currently, this tool only checks prerequisites for Code Ocean deployment.
48 changes: 48 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "co-support"
version = "0.1.0"
authors = [
{ name="Code Ocean", email="dev@codeocean.com" },
]
description = "A tool for managing prerequisites for Code Ocean deployment."
readme = "README.md"
requires-python = ">=3.8"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
dependencies = [
"argparse",
"boto3",
"requests",
"PyYAML",
"prettytable",
"colorama",
"dnspython",
]

[project.scripts]
co-support = "co_support.main:main"

[project.optional-dependencies]
dev = ["pytest", "flake8", "hatch"]

[project.urls]
Homepage = "https://github.com/codeocean/co-support"
Issues = "https://github.com/codeocean/co-support/issues"
Changelog = "https://github.com/codeocean/co-support/blob/main/CHANGELOG.md"

[tool.hatch.build.targets.wheel]
packages = ["src/co_support"]

[tool.hatch.envs.default.scripts]
lint = "flake8 src tests"
test = "pytest"

[[tool.hatch.envs.test.matrix]]
python = ["3.8", "3.9", "3.10", "3.11"]
Empty file added src/co_support/__init__.py
Empty file.
20 changes: 20 additions & 0 deletions src/co_support/cmd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from abc import ABC, abstractmethod
from argparse import ArgumentDefaultsHelpFormatter


class BaseCommand(ABC):
"""
Base class for commands.
"""

def __init__(self, subparsers, name, format_map=None):
self.parser = subparsers.add_parser(
name=name.format_map(format_map),
help=self.__doc__.strip().format_map(format_map),
formatter_class=ArgumentDefaultsHelpFormatter,
)
self.parser.set_defaults(cmd=self.cmd)

@abstractmethod
def cmd(self, args):
pass
27 changes: 27 additions & 0 deletions src/co_support/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python3

import argparse

from co_support.prerequisites.cmd import commands as prerequisites_commands


def parse_args():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers()
prerequisites_commands(subparsers)

return parser.parse_args(), parser


def main():
args, parser = parse_args()
if hasattr(args, 'cmd'):
response = args.cmd(args)
if response:
print(response)
else:
parser.print_help()


if __name__ == '__main__':
main()
Empty file.
Empty file.
Loading