From e5ceacdeaceef2083ec3a346ca6a99f755391ffd Mon Sep 17 00:00:00 2001 From: "Gabriel R. Antunes" Date: Tue, 26 Mar 2024 19:18:07 -0400 Subject: [PATCH] feat: playground with jupyter and .net interactive --- projeto-gerar-horario-playground/Makefile | 11 +++ .../_devops/.gitkeep | 0 .../_devops/Dockerfile | 31 +++++++ .../notebooks/.gitkeep | 0 .../OlaGerador-checkpoint.ipynb | 82 +++++++++++++++++++ .../OlaMundo-checkpoint.ipynb | 30 +++++++ .../notebooks/OlaGerador.ipynb | 82 +++++++++++++++++++ .../notebooks/OlaMundo.ipynb | 30 +++++++ 8 files changed, 266 insertions(+) create mode 100644 projeto-gerar-horario-playground/Makefile create mode 100644 projeto-gerar-horario-playground/_devops/.gitkeep create mode 100644 projeto-gerar-horario-playground/_devops/Dockerfile create mode 100644 projeto-gerar-horario-playground/notebooks/.gitkeep create mode 100644 projeto-gerar-horario-playground/notebooks/.ipynb_checkpoints/OlaGerador-checkpoint.ipynb create mode 100644 projeto-gerar-horario-playground/notebooks/.ipynb_checkpoints/OlaMundo-checkpoint.ipynb create mode 100644 projeto-gerar-horario-playground/notebooks/OlaGerador.ipynb create mode 100644 projeto-gerar-horario-playground/notebooks/OlaMundo.ipynb diff --git a/projeto-gerar-horario-playground/Makefile b/projeto-gerar-horario-playground/Makefile new file mode 100644 index 00000000..1fe25988 --- /dev/null +++ b/projeto-gerar-horario-playground/Makefile @@ -0,0 +1,11 @@ +# user=ladesa + +# start: +# docker build --build-arg USER=$(user) _devops; + +# docker run -it --rm -p 8888:8888 -u $(user) -v $(shell dirname $$(pwd)):/home/user/gerar-horario $$(docker build --build-arg USER=$(user) -q _devops); + +start: + docker build _devops; + + docker run -it --rm -p 8888:8888 -u user -v $(shell dirname $$(pwd)):/home/user/gerar-horario $$(docker build -q _devops); diff --git a/projeto-gerar-horario-playground/_devops/.gitkeep b/projeto-gerar-horario-playground/_devops/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/projeto-gerar-horario-playground/_devops/Dockerfile b/projeto-gerar-horario-playground/_devops/Dockerfile new file mode 100644 index 00000000..e3286f8f --- /dev/null +++ b/projeto-gerar-horario-playground/_devops/Dockerfile @@ -0,0 +1,31 @@ +FROM mcr.microsoft.com/dotnet/sdk:8.0.101 + +RUN apt install -y --no-install-recommends wget && \ + apt autoremove -y && \ + apt clean && \ + rm -rf /var/lib/apt/lists/* + +# Set non-root user +ENV USER="user" +RUN useradd -ms /bin/bash -u 1000 $USER +USER $USER +ENV HOME="/home/$USER" +WORKDIR $HOME + +# Install Anaconda +# RUN wget https://repo.anaconda.com/archive/Anaconda3-2021.05-Linux-x86_64.sh -O anaconda.sh +RUN wget https://repo.anaconda.com/archive/Anaconda3-2024.02-1-Linux-x86_64.sh -O anaconda.sh +RUN chmod +x anaconda.sh +RUN ./anaconda.sh -b -p $HOME/anaconda +RUN rm ./anaconda.sh +ENV PATH="/${HOME}/anaconda/bin:${PATH}" + +# Install .NET kernel +RUN dotnet tool install -g --add-source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" Microsoft.dotnet-interactive +ENV PATH="/${HOME}/.dotnet/tools:${PATH}" +ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 +RUN dotnet interactive jupyter install + +# Run Jupyter Notebook +EXPOSE 8888 +ENTRYPOINT ["jupyter", "notebook", "--no-browser", "--ip=0.0.0.0"] \ No newline at end of file diff --git a/projeto-gerar-horario-playground/notebooks/.gitkeep b/projeto-gerar-horario-playground/notebooks/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/projeto-gerar-horario-playground/notebooks/.ipynb_checkpoints/OlaGerador-checkpoint.ipynb b/projeto-gerar-horario-playground/notebooks/.ipynb_checkpoints/OlaGerador-checkpoint.ipynb new file mode 100644 index 00000000..59c4512f --- /dev/null +++ b/projeto-gerar-horario-playground/notebooks/.ipynb_checkpoints/OlaGerador-checkpoint.ipynb @@ -0,0 +1,82 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 3, + "id": "eb2599d7-7693-4ad7-8b7c-b3f8e49e23c5", + "metadata": {}, + "outputs": [], + "source": [ + "#r \"../../projeto-gerar-horario/GerarHorario/bin/Debug/net8.0/GerarHorario.dll\"" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "b375596e-7023-4eb6-bf8b-dbace732afa8", + "metadata": {}, + "outputs": [], + "source": [ + "using Sisgea.GerarHorario.Core;" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "0fee0429-ba2b-455a-966f-71b00ec3cb1e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Olá, Mundo!\n" + ] + } + ], + "source": [ + "Console.WriteLine(\"Olá, Mundo!\");" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "a8c24654-2664-4cc0-8c0d-3cb22b94c5b8", + "metadata": {}, + "outputs": [ + { + "ename": "Error", + "evalue": "System.IO.FileNotFoundException: Could not load file or assembly 'Google.OrTools, Version=9.9.3963.0, Culture=neutral, PublicKeyToken=c9649d7040f27838'. The system cannot find the file specified.\n\nFile name: 'Google.OrTools, Version=9.9.3963.0, Culture=neutral, PublicKeyToken=c9649d7040f27838'\n at Sisgea.GerarHorario.Core.Gerador.GerarHorario(GerarHorarioOptions options, Boolean verbose)\n at Sisgea.GerarHorario.Core.Main.Retorno() in /mnt/wsl/PHYSICALDRIVE0p1/repositories/@sisgha/current/gerar-horario/projeto-gerar-horario/GerarHorario/Main.cs:line 22\n at Submission#11.<>d__0.MoveNext()\n--- End of stack trace from previous location ---\n at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)", + "output_type": "error", + "traceback": [ + "System.IO.FileNotFoundException: Could not load file or assembly 'Google.OrTools, Version=9.9.3963.0, Culture=neutral, PublicKeyToken=c9649d7040f27838'. The system cannot find the file specified.\n\nFile name: 'Google.OrTools, Version=9.9.3963.0, Culture=neutral, PublicKeyToken=c9649d7040f27838'\n at Sisgea.GerarHorario.Core.Gerador.GerarHorario(GerarHorarioOptions options, Boolean verbose)\n at Sisgea.GerarHorario.Core.Main.Retorno() in /mnt/wsl/PHYSICALDRIVE0p1/repositories/@sisgha/current/gerar-horario/projeto-gerar-horario/GerarHorario/Main.cs:line 22\n at Submission#11.<>d__0.MoveNext()\n--- End of stack trace from previous location ---\n at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)", + " at Sisgea.GerarHorario.Core.Gerador.GerarHorario(GerarHorarioOptions options, Boolean verbose)", + " at Sisgea.GerarHorario.Core.Main.Retorno() in /mnt/wsl/PHYSICALDRIVE0p1/repositories/@sisgha/current/gerar-horario/projeto-gerar-horario/GerarHorario/Main.cs:line 22", + " at Submission#11.<>d__0.MoveNext()", + "--- End of stack trace from previous location ---", + " at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)" + ] + } + ], + "source": [ + "Console.WriteLine((new Main()).Retorno());" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/x-csharp", + "name": "C#", + "pygments_lexer": "csharp", + "version": "12.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/projeto-gerar-horario-playground/notebooks/.ipynb_checkpoints/OlaMundo-checkpoint.ipynb b/projeto-gerar-horario-playground/notebooks/.ipynb_checkpoints/OlaMundo-checkpoint.ipynb new file mode 100644 index 00000000..b6aee98d --- /dev/null +++ b/projeto-gerar-horario-playground/notebooks/.ipynb_checkpoints/OlaMundo-checkpoint.ipynb @@ -0,0 +1,30 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "2db6e9c5-6ee7-448c-9417-52a2dddb1cf7", + "metadata": {}, + "outputs": [], + "source": [ + "Console.WriteLine(\"Olá, Mundo!\");" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/x-csharp", + "name": "C#", + "pygments_lexer": "csharp", + "version": "12.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/projeto-gerar-horario-playground/notebooks/OlaGerador.ipynb b/projeto-gerar-horario-playground/notebooks/OlaGerador.ipynb new file mode 100644 index 00000000..59c4512f --- /dev/null +++ b/projeto-gerar-horario-playground/notebooks/OlaGerador.ipynb @@ -0,0 +1,82 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 3, + "id": "eb2599d7-7693-4ad7-8b7c-b3f8e49e23c5", + "metadata": {}, + "outputs": [], + "source": [ + "#r \"../../projeto-gerar-horario/GerarHorario/bin/Debug/net8.0/GerarHorario.dll\"" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "b375596e-7023-4eb6-bf8b-dbace732afa8", + "metadata": {}, + "outputs": [], + "source": [ + "using Sisgea.GerarHorario.Core;" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "0fee0429-ba2b-455a-966f-71b00ec3cb1e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Olá, Mundo!\n" + ] + } + ], + "source": [ + "Console.WriteLine(\"Olá, Mundo!\");" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "a8c24654-2664-4cc0-8c0d-3cb22b94c5b8", + "metadata": {}, + "outputs": [ + { + "ename": "Error", + "evalue": "System.IO.FileNotFoundException: Could not load file or assembly 'Google.OrTools, Version=9.9.3963.0, Culture=neutral, PublicKeyToken=c9649d7040f27838'. The system cannot find the file specified.\n\nFile name: 'Google.OrTools, Version=9.9.3963.0, Culture=neutral, PublicKeyToken=c9649d7040f27838'\n at Sisgea.GerarHorario.Core.Gerador.GerarHorario(GerarHorarioOptions options, Boolean verbose)\n at Sisgea.GerarHorario.Core.Main.Retorno() in /mnt/wsl/PHYSICALDRIVE0p1/repositories/@sisgha/current/gerar-horario/projeto-gerar-horario/GerarHorario/Main.cs:line 22\n at Submission#11.<>d__0.MoveNext()\n--- End of stack trace from previous location ---\n at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)", + "output_type": "error", + "traceback": [ + "System.IO.FileNotFoundException: Could not load file or assembly 'Google.OrTools, Version=9.9.3963.0, Culture=neutral, PublicKeyToken=c9649d7040f27838'. The system cannot find the file specified.\n\nFile name: 'Google.OrTools, Version=9.9.3963.0, Culture=neutral, PublicKeyToken=c9649d7040f27838'\n at Sisgea.GerarHorario.Core.Gerador.GerarHorario(GerarHorarioOptions options, Boolean verbose)\n at Sisgea.GerarHorario.Core.Main.Retorno() in /mnt/wsl/PHYSICALDRIVE0p1/repositories/@sisgha/current/gerar-horario/projeto-gerar-horario/GerarHorario/Main.cs:line 22\n at Submission#11.<>d__0.MoveNext()\n--- End of stack trace from previous location ---\n at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)", + " at Sisgea.GerarHorario.Core.Gerador.GerarHorario(GerarHorarioOptions options, Boolean verbose)", + " at Sisgea.GerarHorario.Core.Main.Retorno() in /mnt/wsl/PHYSICALDRIVE0p1/repositories/@sisgha/current/gerar-horario/projeto-gerar-horario/GerarHorario/Main.cs:line 22", + " at Submission#11.<>d__0.MoveNext()", + "--- End of stack trace from previous location ---", + " at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)" + ] + } + ], + "source": [ + "Console.WriteLine((new Main()).Retorno());" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/x-csharp", + "name": "C#", + "pygments_lexer": "csharp", + "version": "12.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/projeto-gerar-horario-playground/notebooks/OlaMundo.ipynb b/projeto-gerar-horario-playground/notebooks/OlaMundo.ipynb new file mode 100644 index 00000000..b6aee98d --- /dev/null +++ b/projeto-gerar-horario-playground/notebooks/OlaMundo.ipynb @@ -0,0 +1,30 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "2db6e9c5-6ee7-448c-9417-52a2dddb1cf7", + "metadata": {}, + "outputs": [], + "source": [ + "Console.WriteLine(\"Olá, Mundo!\");" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/x-csharp", + "name": "C#", + "pygments_lexer": "csharp", + "version": "12.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}