forked from Alexey/DAS_2024_1
Compare commits
11 Commits
kuzarin_ma
...
bogdanov_d
| Author | SHA1 | Date | |
|---|---|---|---|
| 0a73e2d5d4 | |||
| 8a96320fd5 | |||
| bd25930973 | |||
| 7184d6d728 | |||
|
|
6e7055efa4 | ||
|
|
9e40adc53c | ||
|
|
4a36528cc7 | ||
| ad3988e5fc | |||
| 780b4b2924 | |||
| 5047b16cde | |||
| 2b87427299 |
2
bazunov_andrew_lab_1/.gitignore
vendored
Normal file
2
bazunov_andrew_lab_1/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
ollama
|
||||
./ollama
|
||||
33
bazunov_andrew_lab_1/README.md
Normal file
33
bazunov_andrew_lab_1/README.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# Распределенные вычисления и приложения Л1
|
||||
## _Автор Базунов Андрей Игревич ПИбд-42_
|
||||
|
||||
В качестве сервисов были выбраны:
|
||||
- 1.Ollama (_Сервис для использования LLMs моделей_)
|
||||
- 2.Open Web Ui (_Сервис для удобного общения с моделью из сервиса Ollama_)
|
||||
- 3.Gitea (_Гит сервис_)
|
||||
|
||||
# Docker
|
||||
|
||||
>Перед исполнением вполняем установку docker и проверяем версию
|
||||
|
||||
```sh
|
||||
docker-compose --version
|
||||
```
|
||||
|
||||
>Далее производим настройку файла docker-compose.yaml и запускаем контейнер
|
||||
|
||||
```sh
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
>Для завершения работы контейнера используем команду
|
||||
```sh
|
||||
docker-compose down
|
||||
```
|
||||
---
|
||||
> Замечание: после запуска контейнера, необходимо перейти в контейнер **ollamа** и выполнить установку модели [gemma2](https://ollama.com/library/gemma2:2b)
|
||||
> ```sh
|
||||
> docker-compose exec ollama ollama run ollama run gemma2:2b
|
||||
> ```
|
||||
---
|
||||
Далее можно использовать веб сервис Open Web Ui по адресу **localhost:8080** для общения с моделью и Gitea по адресу **localhost:3000** - [демонстрация работы](https://vk.com/video/@viltskaa?z=video236673313_456239574%2Fpl_236673313_-2)
|
||||
61
bazunov_andrew_lab_1/docker-compose.yml
Normal file
61
bazunov_andrew_lab_1/docker-compose.yml
Normal file
@@ -0,0 +1,61 @@
|
||||
services:
|
||||
gitea: # Имя сервиса
|
||||
image: gitea/gitea:latest # Имя образа
|
||||
container_name: gitea # Имя контейнера, может быть произовольным
|
||||
ports:
|
||||
- "3000:3000" # Проброс порта Gitea на хост
|
||||
volumes: # хранилище
|
||||
- data:/data
|
||||
environment: # переменные окружения
|
||||
USER_UID: 1000
|
||||
USER_GID: 1000
|
||||
|
||||
ollama:
|
||||
image: ollama/ollama:latest
|
||||
container_name: ollama
|
||||
restart: always
|
||||
ports:
|
||||
- 7869:11434
|
||||
pull_policy: always
|
||||
tty: true
|
||||
volumes:
|
||||
- .:/code
|
||||
- ./ollama/ollama:/root/.ollama # Директория для данных Ollama
|
||||
environment:
|
||||
- OLLAMA_KEEP_ALIVE=24h
|
||||
- OLLAMA_HOST=0.0.0.0 # Указываем хост для API Ollama
|
||||
networks:
|
||||
- ollama-docker
|
||||
command: ["serve"] # Запускаем Ollama в режиме сервера
|
||||
|
||||
ollama-webui:
|
||||
image: ghcr.io/open-webui/open-webui:main # Образ Open Web UI
|
||||
container_name: ollama-webui
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./ollama/ollama-webui:/app/backend/data
|
||||
ports:
|
||||
- 8080:8080 # Порт для веб-интерфейса
|
||||
environment: # https://docs.openwebui.com/getting-started/env-configuration#default_models
|
||||
- OLLAMA_BASE_URLS=http://host.docker.internal:7869
|
||||
- ENV=dev
|
||||
- WEBUI_AUTH=False
|
||||
- WEBUI_NAME=Viltskaa AI
|
||||
- WEBUI_URL=http://localhost:8080
|
||||
- WEBUI_SECRET_KEY=t0p-s3cr3t
|
||||
depends_on:
|
||||
- ollama
|
||||
extra_hosts:
|
||||
- host.docker.internal:host-gateway
|
||||
networks:
|
||||
- ollama-docker
|
||||
|
||||
networks:
|
||||
ollama-docker:
|
||||
external: false
|
||||
|
||||
volumes:
|
||||
ollama:
|
||||
driver: local
|
||||
data:
|
||||
driver: local
|
||||
35
bogdanov_dmitry_lab_1/README.md
Normal file
35
bogdanov_dmitry_lab_1/README.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# Лабораторная работа №1
|
||||
|
||||
## Богданов Дмитрий ПИбд-42
|
||||
|
||||
### Для выполнения были развернуты следующие сервисы:
|
||||
|
||||
* PostgreSQL - база данных
|
||||
* Mediawiki - движок вики
|
||||
* Gitea - движок гита
|
||||
|
||||
### С использованием следующих технологий:
|
||||
|
||||
* git
|
||||
* docker
|
||||
* docker-compose
|
||||
|
||||
|
||||
### Запуск лабораторной:
|
||||
Необходимо перейти в папку с файлом docker-compose.yaml и ввести следующую команду:
|
||||
```
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
## Результат запуска:
|
||||
```
|
||||
[+] Running 4/4
|
||||
✔ Network bogdanov_dmitry_lab_1_default Created 0.0s
|
||||
✔ Container bogdanov_dmitry_lab_1-mediawiki-1 Started 0.7s
|
||||
✔ Container bogdanov_dmitry_lab_1-git-1 Started 0.8s
|
||||
✔ Container bogdanov_dmitry_lab_1-db-1 Started 0.7s
|
||||
```
|
||||
|
||||
## Видео с результатом запуска:
|
||||
|
||||
Видео можно посмотреть по данной [ссылке](https://drive.google.com/file/d/1TES58HIeCnnKbtwWgED2oig4N7plBmol/view).
|
||||
40
bogdanov_dmitry_lab_1/docker-compose.yaml
Normal file
40
bogdanov_dmitry_lab_1/docker-compose.yaml
Normal file
@@ -0,0 +1,40 @@
|
||||
services:
|
||||
# PostgreSQL
|
||||
db:
|
||||
# Образ контейнера
|
||||
image: postgres
|
||||
# Перезапуск при падении
|
||||
restart: always
|
||||
# Порт для подключения
|
||||
ports:
|
||||
- 5432:5432
|
||||
# Каталог с данными. Каталог компьютера:каталог контейнера
|
||||
volumes:
|
||||
- ./volumes/postgres:/var/lib/postgresql/data
|
||||
# Переменные среды для определения хотя бы одного пользователя при запуске
|
||||
environment:
|
||||
- POSTGRES_USER=admin
|
||||
- POSTGRES_PASSWORD=admin
|
||||
# Mediawiki
|
||||
mediawiki:
|
||||
# Образ
|
||||
image: mediawiki
|
||||
# Перезапуск при падении
|
||||
restart: always
|
||||
# Порт для подключения
|
||||
ports:
|
||||
- 8080:80
|
||||
# Каталоги
|
||||
volumes:
|
||||
- ./volumes/mediawiki:/var/www/html/images
|
||||
# Gitea
|
||||
git:
|
||||
image: gitea/gitea:latest
|
||||
restart: always
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "222:22"
|
||||
volumes:
|
||||
- ./volumes/gitea:/data
|
||||
- ./volumes/timezone:/etc/timezone:ro
|
||||
- ./volumes/localtime:/etc/localtime:ro
|
||||
484
kuzarin_maxim_lab_6/.gitignore
vendored
484
kuzarin_maxim_lab_6/.gitignore
vendored
@@ -1,484 +0,0 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from `dotnet new gitignore`
|
||||
|
||||
# dotenv files
|
||||
.env
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# Tye
|
||||
.tye/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.tlog
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||
*.vbp
|
||||
|
||||
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||
*.dsw
|
||||
*.dsp
|
||||
|
||||
# Visual Studio 6 technical files
|
||||
*.ncb
|
||||
*.aps
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# Visual Studio History (VSHistory) files
|
||||
.vshistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
# VS Code files for those working on multiple tools
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
*.code-workspace
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Windows Installer files from build outputs
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# JetBrains Rider
|
||||
*.sln.iml
|
||||
.idea
|
||||
|
||||
##
|
||||
## Visual studio for Mac
|
||||
##
|
||||
|
||||
|
||||
# globs
|
||||
Makefile.in
|
||||
*.userprefs
|
||||
*.usertasks
|
||||
config.make
|
||||
config.status
|
||||
aclocal.m4
|
||||
install-sh
|
||||
autom4te.cache/
|
||||
*.tar.gz
|
||||
tarballs/
|
||||
test-results/
|
||||
|
||||
# Mac bundle stuff
|
||||
*.dmg
|
||||
*.app
|
||||
|
||||
# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
# Vim temporary swap files
|
||||
*.swp
|
||||
@@ -1,25 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.10.34916.146
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeterminantCalculation", "DeterminantCalculation\DeterminantCalculation.csproj", "{31083870-167F-45D9-8205-4E908E4DEAEC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{31083870-167F-45D9-8205-4E908E4DEAEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{31083870-167F-45D9-8205-4E908E4DEAEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{31083870-167F-45D9-8205-4E908E4DEAEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{31083870-167F-45D9-8205-4E908E4DEAEC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {15AF4683-8FFA-462B-AEB1-EBC1DC51E24A}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,10 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,184 +0,0 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
internal class Program
|
||||
{
|
||||
private static string[] _resTableColumnsNames = new string[] { "m*m", "1 t", "2 t", "3 t", "4 t", "5 t", "6 t"};
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine(string.Join("\t", _resTableColumnsNames));
|
||||
for (int i = 8; i < 14; i++)
|
||||
{
|
||||
var e = CreateMatrix(i, i);
|
||||
|
||||
List<long> times = new() { i };
|
||||
|
||||
for (int j = 1; j <= 6; j++)
|
||||
{
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
||||
CalculateDeterminant(e, j);
|
||||
|
||||
sw.Stop();
|
||||
times.Add(sw.ElapsedMilliseconds);
|
||||
}
|
||||
|
||||
Console.WriteLine(string.Join("\t", times));
|
||||
}
|
||||
}
|
||||
|
||||
private static int[,] CreateMatrix(int x, int y)
|
||||
{
|
||||
var rnd = new Random();
|
||||
|
||||
var res = new int[y, x];
|
||||
|
||||
for (int i = 0; i < y; i++)
|
||||
{
|
||||
for (int j = 0; j < x; j++)
|
||||
{
|
||||
res[i, j] = rnd.Next(0, 100);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private static void PritMatrix(int[,] mx)
|
||||
{
|
||||
for (int i = 0; i < mx.GetLength(0); i++)
|
||||
{
|
||||
for (int j = 0; j < mx.GetLength(1); j++)
|
||||
{
|
||||
Console.Write($"{mx[i, j].ToString("000")}\t");
|
||||
}
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
|
||||
public static long CalculateDeterminant(int[,] matrix, int maxThreads)
|
||||
=> CalculateDeterminantParalel(
|
||||
matrix,
|
||||
Enumerable.Range(0, matrix.GetLength(0)).ToArray(),
|
||||
Enumerable.Range(0, matrix.GetLength(1)).ToArray(),
|
||||
maxThreads
|
||||
);
|
||||
|
||||
private static long CalculateDeterminant(int[,] matrix, int[] rows, int[] columns)
|
||||
{
|
||||
if (rows.Length <= 3)
|
||||
return GetSimpleDeterminant(matrix, rows.ToList(), columns.ToList());
|
||||
|
||||
(int fixIndex, bool isFixRow) = GetTheBestRowColumn(matrix, rows, columns);
|
||||
|
||||
long res = 0;
|
||||
int row = isFixRow ? rows[fixIndex] : -1;
|
||||
int column = isFixRow ? -1 : columns[fixIndex];
|
||||
|
||||
for (int index = 0; index < rows.Length; index++)
|
||||
{
|
||||
if (isFixRow)
|
||||
column = columns[index];
|
||||
else
|
||||
row = rows[index];
|
||||
|
||||
res += ((index + fixIndex) % 2 != 0 ? -1 : 1) * matrix[column, row] *
|
||||
CalculateDeterminant(matrix, rows.Where(x => x != row).ToArray(), columns.Where(x => x != column).ToArray());
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private static long CalculateDeterminantParalel(int[,] matrix, int[] rows, int[] columns, int maxThread)
|
||||
{
|
||||
if (rows.Length <= 3)
|
||||
return GetSimpleDeterminant(matrix, rows.ToList(), columns.ToList());
|
||||
|
||||
(int fixIndex, bool isFixRow) = GetTheBestRowColumn(matrix, rows, columns);
|
||||
|
||||
long res = 0;
|
||||
int row = isFixRow ? rows[fixIndex] : -1;
|
||||
int column = isFixRow ? -1 : columns[fixIndex];
|
||||
|
||||
var semaphore = new SemaphoreSlim(maxThread, maxThread);
|
||||
|
||||
for (int index = 0; index < rows.Length; index++)
|
||||
{
|
||||
if (isFixRow)
|
||||
column = columns[index];
|
||||
else
|
||||
row = rows[index];
|
||||
|
||||
var c_column = column;
|
||||
var c_row = row;
|
||||
var c_index = fixIndex + index;
|
||||
semaphore.Wait();
|
||||
Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
res += (c_index % 2 != 0 ? -1 : 1) * matrix[c_column, c_row] *
|
||||
CalculateDeterminant(
|
||||
matrix,
|
||||
rows.Where(x => x != c_row).ToArray(),
|
||||
columns.Where(x => x != c_column).ToArray()
|
||||
);
|
||||
}
|
||||
finally { semaphore.Release(); }
|
||||
});
|
||||
}
|
||||
|
||||
semaphore.Wait(maxThread);
|
||||
return res;
|
||||
}
|
||||
|
||||
private static (int fixIndex, bool isFixRow) GetTheBestRowColumn(int[,] matrix, int[] rows, int[] columns)
|
||||
{
|
||||
Dictionary<int, int> zerosCount = rows.Select(x => x + 1).Union(columns.Select(x => -x - 1)).ToDictionary(x => x, x => 0);
|
||||
|
||||
foreach (var r in rows)
|
||||
{
|
||||
foreach (var c in columns)
|
||||
{
|
||||
if (matrix[r, c] == 0)
|
||||
{
|
||||
zerosCount[r + 1] += 1;
|
||||
zerosCount[-c - 1] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var best = zerosCount.ToList().OrderByDescending(x => x.Value).FirstOrDefault().Key;
|
||||
|
||||
if (best > 0)
|
||||
{
|
||||
return (Array.IndexOf(rows, best - 1), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (Array.IndexOf(columns, -best + 1), false);
|
||||
}
|
||||
}
|
||||
|
||||
private static long GetSimpleDeterminant(int[,] matrix, List<int> rows, List<int> columns)
|
||||
{
|
||||
if (rows.Count == 1)
|
||||
{
|
||||
return matrix[columns[0], rows[0]];
|
||||
}
|
||||
else if (rows.Count == 2)
|
||||
{
|
||||
return matrix[columns[0], rows[0]] * matrix[columns[1], rows[1]] - matrix[columns[0], rows[1]] * matrix[columns[1], rows[0]];
|
||||
}
|
||||
else if (columns.Count == 3)
|
||||
{
|
||||
return matrix[columns[0], rows[0]] * matrix[columns[1], rows[1]] * matrix[columns[2], rows[2]] +
|
||||
matrix[columns[0], rows[1]] * matrix[columns[1], rows[2]] * matrix[columns[2], rows[0]] +
|
||||
matrix[columns[0], rows[2]] * matrix[columns[1], rows[0]] * matrix[columns[2], rows[1]] -
|
||||
|
||||
matrix[columns[0], rows[2]] * matrix[columns[1], rows[1]] * matrix[columns[2], rows[0]] -
|
||||
matrix[columns[1], rows[0]] * matrix[columns[0], rows[1]] * matrix[columns[2], rows[2]] -
|
||||
matrix[columns[0], rows[0]] * matrix[columns[1], rows[2]] * matrix[columns[2], rows[1]];
|
||||
}
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB |
@@ -1,15 +0,0 @@
|
||||
# Лабораторная работа 6
|
||||
Данная работа посвящена параллельному вычислению определителя матриц
|
||||
## Описание
|
||||
Вычисление определителей для матрицы порядка более чем 3, сводится к разложению матрицы по строке (столбцу). Из этого следует, что для нахождения определителя 10-го порядка нужно (в худшем случае) 10 определителей 9-го порядка, что в свою очередь в худшем случае означает, что потребуется 8*9 = 72 определителя 8-го порядка и так далее. Это достаточно трудоёмкая процедура, которую желательно распределить
|
||||
## Запуск
|
||||
Приложение представлет собой консольную программу на C#, которую можно скомпилировать и затем запустит exe файл. В результате в окне консоли появится таблица сравнения времени находления определителя квадратных матриц (размер указан в первой колонке) с использованием разного числа потоков(от 1 до 6). Чем больше размер, тем дольше будет идти расчёт.
|
||||
## Результаты
|
||||
Результаты одного из запусков программы представлены ниже.
|
||||
<br/>
|
||||

|
||||
<br/>
|
||||
Как можно заметить, на небольших размерах распаралеливание приводит только к увеличению времени выполнения (за счёт времени создания Task и синхронизации). Но с ростом размера матрицы использование нескольким потоков начинает приносить значительный выигрыш по производительности. Но в рамках текущей реализации ускориться сильнее определённого предела не получится, что видно из расчёта матрицы 12*12
|
||||
|
||||
## Видеодемонстрация
|
||||
Был записан видеоролик, демонстрирующий процесс запуска и работы системы. Он расположен по [адресу](https://drive.google.com/file/d/1bwJMBa_zKTvZ5PT_xgmrz9SCtEf_ied2/view?usp=sharing)
|
||||
2
tsukanova_irina_lab_2/.gitignore
vendored
Normal file
2
tsukanova_irina_lab_2/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/.venv
|
||||
/.idea
|
||||
16
tsukanova_irina_lab_2/README.md
Normal file
16
tsukanova_irina_lab_2/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Цуканова Ирина ПИбд-32
|
||||
# Лабораторная работа №2 - Разработка простейшего распределённого приложения
|
||||
|
||||
### Язык разработки приложений: Python
|
||||
|
||||
## Выбранные варианты
|
||||
- Для программы 1: Ищет в каталоге ```/var/data``` самый большой по объёму файл и перекладывает его в ```/var/result/data.txt```.
|
||||
- Для программы 2: Сохраняет произведение первого и последнего числа из файла ```/var/result/data.txt``` в ```/var/result/result.txt```.
|
||||
|
||||
## Описание:
|
||||
Каждая программа лежит в своей папке, первая в worker-1, вторая в worker-2.
|
||||
В этих же папках лежат Dockerfile'ы с инструкциями по сборке. В них присутствуют комментарии для значимых строк.
|
||||
Монтированные папки ```data``` для ```/var/data``` и ```result``` для ```/var/result```.
|
||||
|
||||
|
||||
## [Видео](https://drive.google.com/file/d/1eBbIDgTo3MF4EeM677EPEKgJEINekaC0/view?usp=drive_link)
|
||||
1
tsukanova_irina_lab_2/data/file_1.txt
Normal file
1
tsukanova_irina_lab_2/data/file_1.txt
Normal file
@@ -0,0 +1 @@
|
||||
34 905 63 92 74 9 3 25 8 0 2 4 24 452 94 6 2 4 2 65 83 73 672 47 23 21 1
|
||||
1
tsukanova_irina_lab_2/data/file_2.txt
Normal file
1
tsukanova_irina_lab_2/data/file_2.txt
Normal file
@@ -0,0 +1 @@
|
||||
4 9 6 320 75 348 12 75 94 63 45 23 3
|
||||
1
tsukanova_irina_lab_2/data/file_3.txt
Normal file
1
tsukanova_irina_lab_2/data/file_3.txt
Normal file
@@ -0,0 +1 @@
|
||||
5 34 7 9 6 43 5 768 4 23 1 3 657 534 4 3 87 6 9 8 56 37 525 5 7 3 2 65 4 86 7 295 473 254 633 4 45 2
|
||||
18
tsukanova_irina_lab_2/docker-compose.yaml
Normal file
18
tsukanova_irina_lab_2/docker-compose.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
services:
|
||||
|
||||
worker_one:
|
||||
container_name: worker_one
|
||||
build:
|
||||
dockerfile: ./worker-1
|
||||
volumes:
|
||||
- ./data:/var/data
|
||||
- ./result:/var/result
|
||||
|
||||
worker_two:
|
||||
container_name: worker_two
|
||||
build:
|
||||
dockerfile: ./worker-2
|
||||
volumes:
|
||||
- ./result:/var/result
|
||||
depends_on:
|
||||
- worker_one
|
||||
1
tsukanova_irina_lab_2/result/data.txt
Normal file
1
tsukanova_irina_lab_2/result/data.txt
Normal file
@@ -0,0 +1 @@
|
||||
5 34 7 9 6 43 5 768 4 23 1 3 657 534 4 3 87 6 9 8 56 37 525 5 7 3 2 65 4 86 7 295 473 254 633 4 45 2
|
||||
1
tsukanova_irina_lab_2/result/result.txt
Normal file
1
tsukanova_irina_lab_2/result/result.txt
Normal file
@@ -0,0 +1 @@
|
||||
10
|
||||
11
tsukanova_irina_lab_2/worker-1/Dockerfile
Normal file
11
tsukanova_irina_lab_2/worker-1/Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
||||
# Использую базовый образ Python
|
||||
FROM python:3.12-slim
|
||||
|
||||
# Устанавливаю рабочую директорию внутри контейнера
|
||||
WORKDIR /app
|
||||
|
||||
# Копирую все файлы в контейнер
|
||||
COPY worker_1.py .
|
||||
|
||||
# Команда для запуска Python-скрипта
|
||||
CMD ["python", "worker_1.py"]
|
||||
27
tsukanova_irina_lab_2/worker-1/worker_1.py
Normal file
27
tsukanova_irina_lab_2/worker-1/worker_1.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import os
|
||||
import shutil
|
||||
|
||||
# Ищет в каталоге /var/data самый большой по объёму файл и перекладывает его в /var/result/data.txt.
|
||||
print("start worker_1")
|
||||
dir_data = "/var/data"
|
||||
dir_res = "/var/result"
|
||||
|
||||
if not os.path.exists(dir_data):
|
||||
os.mkdir(dir_data)
|
||||
|
||||
if not os.path.exists(dir_res):
|
||||
os.mkdir(dir_res)
|
||||
|
||||
largest_file = None
|
||||
largest_size = 0
|
||||
|
||||
for root, dirs, files in os.walk(dir_data):
|
||||
for file in files:
|
||||
file_path = os.path.join(root, file)
|
||||
file_size = os.path.getsize(file_path)
|
||||
if file_size > largest_size:
|
||||
largest_size = file_size
|
||||
largest_file = file_path
|
||||
|
||||
if largest_file:
|
||||
shutil.copyfile(largest_file, dir_res + "/data.txt")
|
||||
11
tsukanova_irina_lab_2/worker-2/Dockerfile
Normal file
11
tsukanova_irina_lab_2/worker-2/Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
||||
# Использую базовый образ Python
|
||||
FROM python:3.12-slim
|
||||
|
||||
# Устанавливаю рабочую директорию внутри контейнера
|
||||
WORKDIR /app
|
||||
|
||||
# Копирую все файлы в контейнер
|
||||
COPY worker_2.py .
|
||||
|
||||
# Команда для запуска Python-скрипта
|
||||
CMD ["python", "worker_2.py"]
|
||||
19
tsukanova_irina_lab_2/worker-2/worker_2.py
Normal file
19
tsukanova_irina_lab_2/worker-2/worker_2.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# Сохраняет произведение первого и последнего числа из файла /var/result/data.txt в /var/result/result.txt.
|
||||
|
||||
print("start worker_2")
|
||||
|
||||
with open('/var/result/data.txt', 'r') as f:
|
||||
numbers = [int(num) for num in f.read().split() if num.isdigit()]
|
||||
|
||||
if numbers:
|
||||
first_number = numbers[0]
|
||||
last_number = numbers[-1]
|
||||
|
||||
result = first_number * last_number
|
||||
|
||||
with open('/var/result/result.txt', 'w') as f:
|
||||
f.write(f"{result}\n")
|
||||
|
||||
print(f"Получен результат - {result}")
|
||||
else:
|
||||
print("Результат не получен. Файл не содержит чисел")
|
||||
Reference in New Issue
Block a user