-
Notifications
You must be signed in to change notification settings - Fork 6
Auto types #86
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
Draft
martindurant
wants to merge
9
commits into
fsspec:main
Choose a base branch
from
martindurant:auto-types
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Auto types #86
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b7b38fc
clean
martindurant 8702adf
bunch-o-types
martindurant f0195db
Add missing
martindurant 6d15030
metaflow
martindurant 04350f7
Some cleanup and add Panel to API doc
martindurant 9c3390e
Add install suggestions
martindurant 7fa099f
remove raw http suggestions
martindurant dca1bc2
remove unneeded comments
martindurant 8d6ed2a
Add tests
martindurant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| """Infrastructure and deployment artifact types.""" | ||
|
|
||
| from projspec.artifact.base import BaseArtifact, FileArtifact | ||
| from projspec.proj.base import Project | ||
| from projspec.utils import run_subprocess | ||
|
|
||
|
|
||
| class ComposeStack(BaseArtifact): | ||
| """A multi-service stack managed by Docker Compose. | ||
|
|
||
| ``make()`` runs ``docker compose up -d`` | ||
| ``clean()`` runs ``docker compose down`` | ||
| ``state`` is inferred by ``docker compose ps`` (checks for running services). | ||
| """ | ||
|
|
||
| def __init__(self, proj: Project, file: str = "docker-compose.yml", **kwargs): | ||
| self.compose_file = file | ||
| cmd = ["docker", "compose", "-f", file, "up", "-d"] | ||
| super().__init__(proj, cmd=cmd, **kwargs) | ||
|
|
||
| def _make(self, **kwargs): | ||
| run_subprocess(self.cmd, cwd=self.proj.url, output=False, **kwargs) | ||
|
|
||
| def clean(self): | ||
| run_subprocess( | ||
| ["docker", "compose", "-f", self.compose_file, "down"], | ||
| cwd=self.proj.url, | ||
| output=False, | ||
| ) | ||
|
|
||
| def _is_done(self) -> bool: | ||
| try: | ||
| result = run_subprocess( | ||
| ["docker", "compose", "-f", self.compose_file, "ps", "-q"], | ||
| cwd=self.proj.url, | ||
| ) | ||
| return bool(result.stdout.strip()) | ||
| except Exception: | ||
| return False | ||
|
|
||
| def _is_clean(self) -> bool: | ||
| return not self._is_done() | ||
|
|
||
|
|
||
| class StaticSite(FileArtifact): | ||
| """A static website produced by a build tool (MkDocs, Sphinx, Docusaurus, Quarto, etc.). | ||
|
|
||
| ``fn`` should be the glob pattern for the output index file, e.g. | ||
| ``<proj>/site/index.html``. | ||
| """ | ||
|
|
||
| pass | ||
|
|
||
|
|
||
| class TerraformPlan(FileArtifact): | ||
| """A saved Terraform execution plan file (``terraform plan -out plan.tfplan``). | ||
|
|
||
| ``make()`` runs ``terraform plan -out plan.tfplan`` | ||
| ``clean()`` deletes the plan file | ||
| """ | ||
|
|
||
| def __init__(self, proj: Project, plan_file: str = "plan.tfplan", **kwargs): | ||
| fn = f"{proj.url}/{plan_file}" | ||
| cmd = ["terraform", "plan", "-out", plan_file] | ||
| super().__init__(proj, fn=fn, cmd=cmd, **kwargs) | ||
|
|
||
| def clean(self): | ||
| try: | ||
| self.proj.fs.rm(self.fn) | ||
| except FileNotFoundError: | ||
| pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,45 @@ | ||
| """Run definitions that are part of code productionalisation""" | ||
|
|
||
| from dataclasses import dataclass, field | ||
|
|
||
| from projspec.content import BaseContent | ||
|
|
||
|
|
||
| class GithubAction(BaseContent): | ||
| """A run prescription that runs in github on push/merge""" | ||
| @dataclass | ||
| class CIWorkflow(BaseContent): | ||
| """A CI/CD workflow or pipeline definition. | ||
|
|
||
| Captures the name, triggering events, and high-level job/stage names from | ||
| CI configuration files (GitHub Actions, GitLab CI, CircleCI, etc.). | ||
| """ | ||
|
|
||
| name: str = "" | ||
| triggers: list = field(default_factory=list) | ||
| jobs: list = field(default_factory=list) | ||
| provider: str = "" # e.g. "github", "gitlab", "circleci" | ||
|
|
||
|
|
||
| # Keep legacy stub under old name for backwards compatibility | ||
| GithubAction = CIWorkflow | ||
|
|
||
|
|
||
| @dataclass | ||
| class PipelineStage(BaseContent): | ||
| """A named stage or step in a data/ML/workflow pipeline.""" | ||
|
|
||
| name: str = "" | ||
| cmd: list = field(default_factory=list) | ||
| depends_on: list = field(default_factory=list) | ||
|
|
||
|
|
||
| # TODO: we probably want to extract out the jobs and runs, maybe the steps. | ||
| # It may be interesting to provide links to the browser or API to view | ||
| # details. | ||
| ... | ||
| @dataclass | ||
| class ServiceDependency(BaseContent): | ||
| """An external service that a project depends on at runtime. | ||
|
|
||
| Typically exposed via an open TCP port, e.g., as used in container orchestration. | ||
| """ | ||
|
|
||
| # TODO: there are many of these, but we don't extract much information from them | ||
| name: str = "" | ||
| service_type: str = "" # e.g. "postgres", "redis", "kafka" | ||
| version: str = "" | ||
| image: str = "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.