Skip to content

Commit

Permalink
add RepoConfig.options allowing optimization of clone size
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippvK committed Dec 16, 2023
1 parent 02a1e7c commit 6b0ecb0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
25 changes: 24 additions & 1 deletion mlonmcu/environment/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,32 @@ def __repr(self):


class RepoConfig(BaseConfig):
def __init__(self, url, ref=None):
def __init__(self, url, ref=None, options=None):
self.url = url
if ref is not None:
assert isinstance(ref, str)
self.ref = ref
self.options = options if options is not None else {}
assert isinstance(self.options, dict)

@property
def single_branch(self):
value = self.options.get("single_branch", False)

Check failure on line 139 in mlonmcu/environment/config.py

View workflow job for this annotation

GitHub Actions / Flake8

mlonmcu/environment/config.py#L139

Indentation is not a multiple of 4 (E111)
assert isinstance(value, bool)

Check failure on line 140 in mlonmcu/environment/config.py

View workflow job for this annotation

GitHub Actions / Flake8

mlonmcu/environment/config.py#L140

Indentation is not a multiple of 4 (E111)
return value

Check failure on line 141 in mlonmcu/environment/config.py

View workflow job for this annotation

GitHub Actions / Flake8

mlonmcu/environment/config.py#L141

Indentation is not a multiple of 4 (E111)

@property
def recursive(self):
value = self.options.get("recursive", True)

Check failure on line 145 in mlonmcu/environment/config.py

View workflow job for this annotation

GitHub Actions / Flake8

mlonmcu/environment/config.py#L145

Indentation is not a multiple of 4 (E111)
assert isinstance(value, bool)

Check failure on line 146 in mlonmcu/environment/config.py

View workflow job for this annotation

GitHub Actions / Flake8

mlonmcu/environment/config.py#L146

Indentation is not a multiple of 4 (E111)
return value

Check failure on line 147 in mlonmcu/environment/config.py

View workflow job for this annotation

GitHub Actions / Flake8

mlonmcu/environment/config.py#L147

Indentation is not a multiple of 4 (E111)

@property
def submodules(self):
value = self.options.get("submodules", None)

Check failure on line 151 in mlonmcu/environment/config.py

View workflow job for this annotation

GitHub Actions / Flake8

mlonmcu/environment/config.py#L151

Indentation is not a multiple of 4 (E111)
if value is not None:

Check failure on line 152 in mlonmcu/environment/config.py

View workflow job for this annotation

GitHub Actions / Flake8

mlonmcu/environment/config.py#L152

Indentation is not a multiple of 4 (E111)
assert isinstance(value, list)

Check failure on line 153 in mlonmcu/environment/config.py

View workflow job for this annotation

GitHub Actions / Flake8

mlonmcu/environment/config.py#L153

Indentation is not a multiple of 4 (E111)
return value

Check failure on line 154 in mlonmcu/environment/config.py

View workflow job for this annotation

GitHub Actions / Flake8

mlonmcu/environment/config.py#L154

Indentation is not a multiple of 4 (E111)


class BackendConfig(BaseConfig):
Expand Down
10 changes: 5 additions & 5 deletions mlonmcu/environment/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ def load_environment_from_file(filename, base):
repos = {}
for key in loaded["repos"]:
repo = loaded["repos"][key]
if "url" not in repo:
url = repo.get("url", None)
if url is None:
raise RuntimeError("Missing field 'url' in YAML file")
if "ref" in repo:
repos[key] = RepoConfig(repo["url"], ref=repo["ref"])
else:
repos[key] = RepoConfig(repo["url"])
ref = repo.get("ref", None)
options = repo.get("options", None)
repos[key] = RepoConfig(url, ref=ref, options=options)
else:
repos = None
default_framework = None
Expand Down
1 change: 1 addition & 0 deletions mlonmcu/environment/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def create_environment_dict(environment):
for path, path_config in environment.paths.items()
} # TODO: allow relative paths
data["repos"] = {repo: vars(repo_config) for repo, repo_config in environment.repos.items()}
# TODO: test with options!
data["frameworks"] = {
"default": environment.defaults.default_framework if environment.defaults.default_framework else None,
**{
Expand Down

0 comments on commit 6b0ecb0

Please sign in to comment.