Skip to content

Commit

Permalink
Adds devcontainer to Hatchet to help with things like formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ilumsden committed Nov 14, 2024
1 parent db076f6 commit 6179835
Show file tree
Hide file tree
Showing 16 changed files with 287 additions and 43 deletions.
60 changes: 60 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
FROM continuumio/miniconda3:24.9.2-0

USER root

ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=1000
ENV USERNAME=${USERNAME}
ENV USER_UID=${USER_UID}
ENV USER_GID=${USER_GID}

RUN apt-get update -q \
&& apt-get install -q -y --no-install-recommends \
build-essential \
ripgrep \
pandoc \
adduser \
git \
grep \
curl \
wget \
vim

RUN conda install -y python=3.9 \
&& pip install --no-cache-dir pipx \
&& pipx reinstall-all

RUN conda install -c conda-forge gh jupyterlab

COPY requirements.txt /requirements.txt

RUN python3 -m pip install -r requirements.txt

RUN python3 -m pip install --upgrade flake8-pytest-importorskip click==8.0.4 black==24.4.2 flake8==4.0.1

RUN groupadd -g ${USER_GID} ${USERNAME} && \
adduser --disabled-password --uid ${USER_UID} --gid ${USER_GID} --gecos "" ${USERNAME} && \
echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers

USER $USERNAME

# FROM mcr.microsoft.com/devcontainers/miniconda:1-3
#
# # Copy environment.yml (if found) to a temp location so we update the environment. Also
# # copy "noop.txt" so the COPY instruction does not fail if no environment.yml exists.
# COPY environment.yml* .devcontainer/noop.txt /tmp/conda-tmp/
# RUN if [ -f "/tmp/conda-tmp/environment.yml" ]; then umask 0002 && /opt/conda/bin/conda env update -n base -f /tmp/conda-tmp/environment.yml; fi \
# && rm -rf /tmp/conda-tmp
#
# COPY requirements.txt /requirements.txt
#
# RUN conda install -y python=3.9 \
# && pip install --no-cache-dir pipx \
# && pipx reinstall-all
#
#
# # [Optional] Uncomment this section to install additional OS packages.
# # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# # && apt-get -y install --no-install-recommends <your-package-list-here>

81 changes: 81 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/miniconda
{
"name": "Hatchet Python 3.9",
"build": {
"context": "..",
"dockerfile": "Dockerfile"
},
// "features": {
// // "ghcr.io/devcontainers/features/git:1": {
// // "ppa": true,
// // "version": "os-provided"
// // },
// // "ghcr.io/devcontainers/features/git-lfs:1": {
// // "autoPull": true,
// // "version": "latest"
// // },
// "ghcr.io/devcontainers/features/github-cli:1": {
// "installDirectlyFromGitHubRelease": true,
// "version": "latest"
// }
// // "ghcr.io/devcontainers/features/python:1": {
// // "installTools": true,
// // "toolsToInstall": "autopep8,yapf,pydocstyle,pycodestyle,bandit,pytest,pylint",
// // "enableShared": true,
// // "installJupyterlab": true,
// // "version": "3.9"
// // },
// // "ghcr.io/devcontainers-extra/features/act:1": {
// // "version": "latest"
// // },
// // "ghcr.io/devcontainers-extra/features/curl-apt-get:1": {},
// // "ghcr.io/devcontainers-extra/features/fd:1": {
// // "version": "latest"
// // },
// // "ghcr.io/devcontainers-extra/features/fzf:1": {
// // "version": "latest"
// // },
// // "ghcr.io/devcontainers-extra/features/ripgrep:1": {
// // "version": "latest"
// // },
// // "ghcr.io/devcontainers-extra/features/wget-apt-get:1": {}
// },
// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-python.black-formatter",
"ms-python.flake8",
"dbaeumer.vscode-eslint",
"ms-python.debugpy",
"ms-toolsai.jupyter"
],
"settings": {
"python.defaultInterpreterPath": "/opt/conda/bin/python3",
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true
},
"python.formatting.provider": "black",
"python.formatting.blackPath": "/opt/conda/bin/black",
"black-formatter.path": [
"/opt/conda/bin/black"
]
}
}
},
"remoteEnv": {
"PATH": "/opt/conda/bin:${containerEnv:PATH}",
"EDITOR": "/usr/bin/vim"
}
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "echo \"export PATH=$CURRENT_PYTHON_BINDIR:\\$PATH\" >> ~/.bashrc"
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
7 changes: 6 additions & 1 deletion hatchet/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
#
# SPDX-License-Identifier: MIT

import sys
from collections import defaultdict
from collections.abc import Iterable
from typing import Any, Dict, List, Optional, Set, Tuple, Union

if sys.version_info >= (3, 9):
from collections.abc import Iterable
else:
from typing import Iterable

from .node import Node, traversal_order, node_traversal_order


Expand Down
6 changes: 5 additions & 1 deletion hatchet/graphframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@
import sys
import traceback
from collections import defaultdict
from collections.abc import Callable, Iterable
from typing import Any, Dict, List, Optional, Set, Tuple, Union, cast
from io import TextIOWrapper

if sys.version_info >= (3, 9):
from collections.abc import Callable, Iterable
else:
from typing import Callable, Iterable

import multiprocess as mp
import numpy as np
import pandas as pd
Expand Down
7 changes: 6 additions & 1 deletion hatchet/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
#
# SPDX-License-Identifier: MIT

import sys
from functools import total_ordering
from typing import Any, Dict, List, Optional, Set, Tuple, Union
from collections.abc import Iterable

if sys.version_info >= (3, 9):
from collections.abc import Iterable
else:
from typing import Iterable

from .frame import Frame

Expand Down
7 changes: 6 additions & 1 deletion hatchet/query/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@

import sys
import warnings
from collections.abc import Callable
from typing import List, Optional, Union, cast, TYPE_CHECKING

if sys.version_info >= (3, 9):
from collections.abc import Callable
else:
from typing import Callable


from ..node import Node
from .query import Query
from .compound import (
Expand Down
6 changes: 5 additions & 1 deletion hatchet/query/object_dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
import re
import sys
from typing import Dict, List, Tuple, Union
from collections.abc import Callable, Iterable

if sys.version_info >= (3, 9):
from collections.abc import Callable, Iterable
else:
from typing import Callable, Iterable

from .errors import InvalidQueryPath, InvalidQueryFilter, MultiIndexModeMismatch
from ..node import Node
Expand Down
7 changes: 6 additions & 1 deletion hatchet/query/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
#
# SPDX-License-Identifier: MIT

import sys
from typing import List, Tuple, Union
from collections.abc import Callable, Iterator

if sys.version_info >= (3, 9):
from collections.abc import Callable, Iterator
else:
from typing import Callable, Iterator

from .errors import InvalidQueryPath

Expand Down
Loading

0 comments on commit 6179835

Please sign in to comment.