Skip to content

Commit

Permalink
feat: playground with jupyter and .net interactive
Browse files Browse the repository at this point in the history
  • Loading branch information
guesant committed Mar 26, 2024
1 parent 9156466 commit e5ceacd
Show file tree
Hide file tree
Showing 8 changed files with 266 additions and 0 deletions.
11 changes: 11 additions & 0 deletions projeto-gerar-horario-playground/Makefile
Original file line number Diff line number Diff line change
@@ -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);
Empty file.
31 changes: 31 additions & 0 deletions projeto-gerar-horario-playground/_devops/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
Empty file.
Original file line number Diff line number Diff line change
@@ -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.<<Initialize>>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.<<Initialize>>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.<<Initialize>>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
}
Original file line number Diff line number Diff line change
@@ -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
}
82 changes: 82 additions & 0 deletions projeto-gerar-horario-playground/notebooks/OlaGerador.ipynb
Original file line number Diff line number Diff line change
@@ -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.<<Initialize>>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.<<Initialize>>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.<<Initialize>>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
}
30 changes: 30 additions & 0 deletions projeto-gerar-horario-playground/notebooks/OlaMundo.ipynb
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit e5ceacd

Please sign in to comment.