From 92cf73da41437638ff2870e70dcc53b3c8e99398 Mon Sep 17 00:00:00 2001 From: Mikhail Tavarez Date: Wed, 31 Jul 2024 13:41:21 -0500 Subject: [PATCH] add devcontainer --- .devcontainer/Dockerfile | 76 +++++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 18 ++++++++ README.md | 5 ++- 3 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..9b7e42d --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,76 @@ +# ===----------------------------------------------------------------------=== # +# Copyright (c) 2023, Modular Inc. All rights reserved. +# +# Licensed under the Apache License v2.0 with LLVM Exceptions: +# https://llvm.org/LICENSE.txt +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# The Dockerfile is provided as reference. Please review the redistribution +# terms of the Mojo license in Section 1 (https://www.modular.com/legal/mojo) +# prior to distributing pre-built container images. +# ===----------------------------------------------------------------------=== # + +# Example command line: +# Use no-cache to force docker to rebuild layers of the image by downloading the SDK from the repos +# ./build-image.sh --auth-key +# + +FROM ubuntu:22.04 + +ARG DEFAULT_TZ=America/Los_Angeles +ENV DEFAULT_TZ=$DEFAULT_TZ + +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive TZ=$DEFAULT_TZ apt-get install -y \ + tzdata \ + vim \ + nano \ + sudo \ + curl \ + wget \ + python3-pip \ + git && \ + rm -rf /var/lib/apt/lists/* + + +# Download the latest version of minicoda py3.8 for linux x86/x64. +# RUN curl -fsSL https://repo.anaconda.com/miniconda/$( wget -O - https://repo.anaconda.com/miniconda/ 2>/dev/null | grep -o 'Miniconda3-py38_[^"]*-Linux-x86_64.sh' | head -n 1) > /tmp/miniconda.sh \ +# && chmod +x /tmp/miniconda.sh \ +# && /tmp/miniconda.sh -b -p /opt/conda + +# RUN mkdir -p ~/miniconda3 \ +# && wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh \ +# && bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3 \ +# && rm -rf ~/miniconda3/miniconda.sh + +# ENV PATH=~/miniconda3/bin/conda:$PATH +# RUN conda init + +RUN pip install \ + pytest \ + git+https://github.com/guidorice/mojo-pytest.git + +# RUN pip install \ +# jupyterlab \ +# ipykernel \ +# matplotlib \ +# ipywidgets + +RUN curl https://get.modular.com | sh - +RUN modular auth examples && modular install nightly/mojo +# RUN modular auth examples && modular install mojo + +ARG MODULAR_HOME="/root/.modular" +ENV MODULAR_HOME=$MODULAR_HOME +ENV PATH="$PATH:$MODULAR_HOME/pkg/packages.modular.com_nightly_mojo/bin" +# ENV PATH="$PATH:$MODULAR_HOME/pkg/packages.modular.com_mojo/bin" + +# Change permissions to allow for Apptainer/Singularity containers +RUN chmod -R a+rwX /root + +# CMD ["jupyter", "lab", "--ip='*'", "--NotebookApp.token=''", "--NotebookApp.password=''","--allow-root"] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..4ef9288 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,18 @@ +{ + "name": "Mojo", + "build": { + "dockerfile": "Dockerfile" + }, + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Set *default* container specific settings.json values on container create. + "settings": {}, + "extensions": [ + "modular-mojotools.vscode-mojo", + // "ms-toolsai.jupyter" + // "modular-mojotools.vscode-mojo-nightly" + ] + } + } +} diff --git a/README.md b/README.md index 70ffd2f..6970546 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,10 @@ WIP Logger! Inspired by charmbracelet's `log` package and the Python `structlog` package. -There are some things I'm ironing out around terminal color profile querying at compilation time. At the moment, the default styles assume a `TRUE_COLOR` enabled color profile. So, if your terminal only supports `ANSI` or `ANSI256`, try setting custom styles like in the `custom.mojo` example, or update the default profile in `stump/style.mojo` from `TRUE_COLOR` to `ANSI` or `ANSI256`. +For the easiest usage method, I recommend just copying the entire `external` folder into your repository, then copy the `stump` folder into the external folder as well. +Mojo segfaults when trying to use top-level file scope vars from `mojopkg` files, so it will most likely segfault is you tried to use this in that way currently. -See the examples directory for examples on setting up custom processors, styling, message only/json/logfmt logging, and logging with the styling turned off! +See the examples directory for examples on setting up custom processors, styling, message only/json/logfmt logging, and logging with the styling turned off. There's support for arbitrary arg pairs and kwargs to be merged into the log statement!