Skip to content

Commit

Permalink
Updated formatting of Python scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
tdulcet committed Jun 10, 2024
1 parent d14692c commit 8b03cef
Show file tree
Hide file tree
Showing 9 changed files with 1,822 additions and 1,163 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jobs:
python3 -m pip install --upgrade pip
python3 -m pip install pylint
- name: Script
run: pylint -f github --py-version 2.6 -d design,C0103,W0311,C0301,C0302,C0209 --load-plugins pylint.extensions.code_style,pylint.extensions.comparison_placement,pylint.extensions.for_any_all,pylint.extensions.consider_refactoring_into_while_condition,pylint.extensions.consider_ternary_expression,pylint.extensions.dict_init_mutate,pylint.extensions.docstyle,pylint.extensions.check_elif,pylint.extensions.set_membership,pylint.extensions.typing -e R6104,C1804,C1805 -r y *.py mprime-python-port/*.py
run: pylint -f github --py-version 2.6 -d design,C0103,W0311,C0301,C0302,C0209,R1702 --load-plugins pylint.extensions.code_style,pylint.extensions.comparison_placement,pylint.extensions.for_any_all,pylint.extensions.consider_refactoring_into_while_condition,pylint.extensions.consider_ternary_expression,pylint.extensions.dict_init_mutate,pylint.extensions.docstyle,pylint.extensions.check_elif,pylint.extensions.set_membership,pylint.extensions.typing -e R6104,C1804,C1805 -r y *.py mprime-python-port/*.py
continue-on-error: true

Ruff:
Expand All @@ -141,7 +141,7 @@ jobs:
python3 -m pip install --upgrade pip
python3 -m pip install ruff
- name: Script
run: ruff check --output-format=github --target-version py37 --select F,E4,E7,E9,W,I,D,UP,YTT,S,BLE,B,A,COM819,C4,T10,EM,EXE,ISC,ICN,G,PIE,PYI,Q,RSE,RET,SLF,SLOT,SIM,TID,TCH,ARG,PGH,PL,TRY,PERF,FURB,LOG,RUF --preview --ignore W191,D211,D213,D401,UP004,UP009,UP010,UP024,UP030,UP032,UP036,PYI024,PLR09,PLR1702,PLR2004,S324,S404,S603,FURB101,FURB167,RUF001,RUF002,RUF003,RUF005,RUF023 .
run: ruff check --output-format=github --target-version py37 --select F,E4,E7,E9,W,I,D,UP,YTT,S,BLE,B,A,COM819,C4,T10,EM,EXE,ISC,ICN,G,PIE,PYI,Q,RSE,RET,SLF,SLOT,SIM,TID,TCH,ARG,PGH,PL,TRY,PERF,FURB,LOG,RUF --preview --ignore W191,D211,D213,D401,UP004,UP008,UP009,UP010,UP024,UP030,UP032,UP036,PYI024,PLR09,PLR1702,PLR2004,S324,S404,S603,FURB101,FURB167,RUF001,RUF002,RUF003,RUF005,RUF023 .
continue-on-error: true

Linux:
Expand Down Expand Up @@ -213,5 +213,11 @@ jobs:
Get-CimInstance Win32_Processor | Select MaxClockSpeed
wmic memphysical get MaxCapacity
Get-CimInstance Win32_PhysicalMemoryArray | Select MaxCapacity
wmic ComputerSystem get TotalPhysicalMemory
Get-CimInstance Win32_ComputerSystem | Select TotalPhysicalMemory
wmic cpu get L2CacheSize,L3CacheSize
Get-CimInstance Win32_Processor | Select L2CacheSize,L3CacheSize
wmic path Win32_CacheMemory get CacheType,InstalledSize,Level
Get-CimInstance Win32_CacheMemory | Select CacheType,InstalledSize,Level
python -X dev -c "import platform; print(platform.win32_ver())"
python -X dev primenet.py --help
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ Options:
--max-exp=MAX_EXP Maximum exponent to get from PrimeNet (2 -
999,999,999)
-g, --gpuowl, --prpll
Get assignments for GpuOwl or PRPLL instead of
Mlucas.
Get assignments for GpuOwl or PRPLL instead of Mlucas.
--cudalucas=CUDALUCAS
Get assignments for CUDALucas instead of Mlucas.
Provide the CUDALucas output filename as the argument.
Expand Down
79 changes: 44 additions & 35 deletions google-colab/Colab CPU MPrime.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,66 +16,73 @@
"metadata": {},
"outputs": [],
"source": [
"#@title # **📔 Colab CPU Notebook**#{ vertical-output: true, display-mode: \"form\" }\n",
"# @title # **📔 Colab CPU Notebook**#{ vertical-output: true, display-mode: \"form\" }\n",
"\n",
"import os\n",
"\n",
"#@markdown #### ↖️ Click the ▶️ button after deciding on the options below.\n",
"#@markdown #### 💡 Keep each notebook **open** in the browser to prevent disconnection. 📌 [the tab](https://support.mozilla.org/kb/pinned-tabs-keep-favorite-websites-open) or move them to a dedicated window for easy access.\n",
"#@markdown #### ℹ️ This notebook uses our Prime95 [Bash install script](https://github.com/tdulcet/Distributed-Computing-Scripts#organizations).\n",
"#@markdown #### 📜 Please see the [documentation](https://github.com/tdulcet/Distributed-Computing-Scripts/tree/master/google-colab) for more information and to ❤️ support us.\n",
"#@markdown #### 🤷 Optionally, create a GIMPS/PrimeNet account [here](https://www.mersenne.org/update/) and [join](https://www.mersenne.org/jteam/) the “Portland State University” team!\n",
"\n",
"prime_ID = 'Default' #@param ['Default'] {allow-input: true}\n",
"computer_name = 'Default' #@param ['Default'] {allow-input: true}\n",
"type_of_work = '150 - First time PRP tests' #@param ['0 - Whatever makes the most sense', '1 - Trial factoring to low limits', '2 - Trial factoring', '4 - P-1 factoring', '5 - ECM for first factors of Mersenne numbers', '6 - ECM on Fermat numbers', '8 - ECM on Mersenne cofactors', '100 - First time LL tests', '101 - Double-check LL tests', '102 - World record LL tests', '104 - 100 million digit LL tests', '150 - First time PRP tests', '151 - Double-check PRP tests', '152 - World record PRP tests', '153 - 100 million digit PRP tests', '154 - First time PRP tests that need P-1 factoring', '155 - Double-check tests using PRP with proof', '160 - First time PRP on Mersenne cofactors', '161 - Double-check PRP on Mersenne cofactors']\n",
"prp_proof_power = '5' #@param ['Default', '5', '6', '7', '8', '9', '10', '11', '12']\n",
"prp_proof_power_mult = 'Default' #@param ['Default', '1', '2', '3', '4']\n",
"#@markdown Every lower power halves Drive storage requirements for PRP tests, but doubles the certification cost. Drive storage (GiB) needed for PRP tests:\n",
"\n",
"#@markdown Proof<br>Power | Exponent 50M | Exponent 100M | Exponent 150M | Exponent 200M | Exponent 250M | Exponent 300M | Exponent 332.1M<br>(100M digits)\n",
"#@markdown --- | ---: | ---: | ---: | ---: | ---: | ---: | ---:\n",
"#@markdown 5 | 0.186 | 0.372 | 0.558 | 0.745 | 0.931 | 1.117 | 1.237\n",
"#@markdown 6 | 0.372 | 0.745 | 1.117 | 1.49 | 1.862 | 2.235 | 2.475\n",
"#@markdown 7 | 0.745 | 1.49 | 2.235 | *2.98* | *3.725* | *4.47* | *4.95*\n",
"#@markdown 8 | 1.49 | *2.98* | *4.47* | 5.96 | 7.45 | 8.94 | 9.9\n",
"#@markdown 9 | ***2.98*** | **5.96** | 8.94 | 11.92 | 14.9 | 17.88 | 19.8\n",
"#@markdown 10 | 5.96 | 11.92 | **17.88** | **23.84** | **29.8** | **35.76** | **39.6**\n",
"#@markdown 11 | 11.92 | 23.84 | 35.76 | 47.68 | 59.6 | 71.52 | 79.2\n",
"#@markdown 12 | 23.84 | 47.68 | 71.52 | 95.36 | 119.2 | 143 | 158.4\n",
"proof_certification_work = True #@param {type:\"boolean\"}\n",
"computer_number = 'Default (1)' #@param ['Default (1)', '2', '3', '4']{allow-input: true}\n",
"local_time = 'Pacific' #@param ['Pacific', 'Mountain', 'Central', 'Eastern', 'Alaska', 'Hawaii']\n",
"debug = 'False' #@param ['False', 'CPU (Prime95)']\n",
"\n",
"#@markdown #### 🐛 The *debug* option outputs CPU (Prime95/MPrime) progress and status, then exits.\n",
"# @markdown #### ↖️ Click the ▶️ button after deciding on the options below.\n",
"# @markdown #### 💡 Keep each notebook **open** in the browser to prevent disconnection. 📌 [the tab](https://support.mozilla.org/kb/pinned-tabs-keep-favorite-websites-open) or move them to a dedicated window for easy access.\n",
"# @markdown #### ℹ️ This notebook uses our Prime95 [Bash install script](https://github.com/tdulcet/Distributed-Computing-Scripts#organizations).\n",
"# @markdown #### 📜 Please see the [documentation](https://github.com/tdulcet/Distributed-Computing-Scripts/tree/master/google-colab) for more information and to ❤️ support us.\n",
"# @markdown #### 🤷 Optionally, create a GIMPS/PrimeNet account [here](https://www.mersenne.org/update/) and [join](https://www.mersenne.org/jteam/) the “Portland State University” team!\n",
"\n",
"prime_ID = 'Default' # @param ['Default'] {allow-input: true}\n",
"computer_name = 'Default' # @param ['Default'] {allow-input: true}\n",
"type_of_work = '150 - First time PRP tests' # @param ['0 - Whatever makes the most sense', '1 - Trial factoring to low limits', '2 - Trial factoring', '4 - P-1 factoring', '5 - ECM for first factors of Mersenne numbers', '6 - ECM on Fermat numbers', '8 - ECM on Mersenne cofactors', '100 - First time LL tests', '101 - Double-check LL tests', '102 - World record LL tests', '104 - 100 million digit LL tests', '150 - First time PRP tests', '151 - Double-check PRP tests', '152 - World record PRP tests', '153 - 100 million digit PRP tests', '154 - First time PRP tests that need P-1 factoring', '155 - Double-check tests using PRP with proof', '160 - First time PRP on Mersenne cofactors', '161 - Double-check PRP on Mersenne cofactors']\n",
"prp_proof_power = '5' # @param ['Default', '5', '6', '7', '8', '9', '10', '11', '12']\n",
"prp_proof_power_mult = 'Default' # @param ['Default', '1', '2', '3', '4']\n",
"# @markdown Every lower power halves Drive storage requirements for PRP tests, but doubles the certification cost. Drive storage (GiB) needed for PRP tests:\n",
"\n",
"# @markdown Proof<br>Power | Exponent 50M | Exponent 100M | Exponent 150M | Exponent 200M | Exponent 250M | Exponent 300M | Exponent 332.1M<br>(100M digits)\n",
"# @markdown --- | ---: | ---: | ---: | ---: | ---: | ---: | ---:\n",
"# @markdown 5 | 0.186 | 0.372 | 0.558 | 0.745 | 0.931 | 1.117 | 1.237\n",
"# @markdown 6 | 0.372 | 0.745 | 1.117 | 1.49 | 1.862 | 2.235 | 2.475\n",
"# @markdown 7 | 0.745 | 1.49 | 2.235 | *2.98* | *3.725* | *4.47* | *4.95*\n",
"# @markdown 8 | 1.49 | *2.98* | *4.47* | 5.96 | 7.45 | 8.94 | 9.9\n",
"# @markdown 9 | ***2.98*** | **5.96** | 8.94 | 11.92 | 14.9 | 17.88 | 19.8\n",
"# @markdown 10 | 5.96 | 11.92 | **17.88** | **23.84** | **29.8** | **35.76** | **39.6**\n",
"# @markdown 11 | 11.92 | 23.84 | 35.76 | 47.68 | 59.6 | 71.52 | 79.2\n",
"# @markdown 12 | 23.84 | 47.68 | 71.52 | 95.36 | 119.2 | 143 | 158.4\n",
"proof_certification_work = True # @param {type:\"boolean\"}\n",
"computer_number = 'Default (1)' # @param ['Default (1)', '2', '3', '4']{allow-input: true}\n",
"local_time = 'Pacific' # @param ['Pacific', 'Mountain', 'Central', 'Eastern', 'Alaska', 'Hawaii']\n",
"debug = 'False' # @param ['False', 'CPU (Prime95)']\n",
"\n",
"# @markdown #### 🐛 The *debug* option outputs CPU (Prime95/MPrime) progress and status, then exits.\n",
"\n",
"\n",
"class StopExecution(Exception):\n",
" def _render_traceback_(self):\n",
" pass\n",
" pass\n",
"\n",
"\n",
"def load_drive():\n",
" '''Load & cd into gdrive for persistent data.'''\n",
" if os.path.exists('/content/drive/My Drive'): # create your own notebook with our code\n",
" if os.path.exists('/content/drive/My Drive'): # create your own notebook with our code\n",
" %cd \"/content/drive/My Drive\"\n",
" else: # use our notebook\n",
" else: # use our notebook\n",
" print('Warning: Google Drive is not mounted')\n",
" print('If you were not expecting this, on the far left click the folder icon, the \"Mount Drive\" folder button, select \"CONNECT TO GOOGLE DRIVE\" ')\n",
" print(\n",
" 'If you were not expecting this, on the far left click the folder icon, the \"Mount Drive\" folder button, select \"CONNECT TO GOOGLE DRIVE\" '\n",
" )\n",
" print('and then re-execute this cell.')\n",
" from google.colab import drive\n",
"\n",
" drive.mount('/content/gdrive')\n",
" %cd \"/content/gdrive/My Drive/\"\n",
" if 'My Drive/GIMPS' in os.getcwd(): # don't create a subfolder in GIMPS/\n",
" if 'My Drive/GIMPS' in os.getcwd(): # don't create a subfolder in GIMPS/\n",
" return\n",
" os.makedirs('GIMPS', exist_ok=True)\n",
" %cd \"GIMPS\"\n",
"\n",
"\n",
"def run():\n",
" '''Run MPrime.'''\n",
" os.chmod('mprime_cpu/mprime', 0o777)\n",
" print('\\nStarting Prime95\\n')\n",
" !cd mprime_cpu && ./mprime -A{computer_number} -d | tee -ia '{'cpu' + computer_number + '.out'}'\n",
"\n",
"\n",
"def debug_exit():\n",
" '''Output of Prime95 CPU outputs.'''\n",
" if debug == 'CPU (Prime95)' and os.path.exists(f'mprime_cpu/cpu{computer_number}.out'):\n",
Expand All @@ -87,6 +94,7 @@
" else:\n",
" print(f'No `{debug!r}` output file found for debug option and computer number `{computer_number!r}`.\\n')\n",
"\n",
"\n",
"def install():\n",
" '''Download/Install/Configure Prime95.'''\n",
" !wget -nv -O master.zip https://github.com/tdulcet/Distributed-Computing-Scripts/archive/master.zip\n",
Expand Down Expand Up @@ -114,6 +122,7 @@
" !mv temp.txt '{file}'\n",
" run()\n",
"\n",
"\n",
"!wget -qO - https://raw.github.com/tdulcet/Linux-System-Information/master/info.sh | bash -s # Check System Info\n",
"!python3 -V\n",
"print()\n",
Expand Down
Loading

0 comments on commit 8b03cef

Please sign in to comment.