Skip to content

Commit

Permalink
Updated with new abuseipdb and nicer js bundling
Browse files Browse the repository at this point in the history
  • Loading branch information
adonm committed Mar 23, 2024
1 parent 0b0b5dc commit c1076db
Show file tree
Hide file tree
Showing 12 changed files with 252 additions and 4,795 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
uses: fastai/workflows/quarto-ghp@master
with:
version: '3.11'
- name: npm build
run: npm install && npm run build
- name: npm release upload
- name: build
run: build.sh
- name: release upload
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: atlaskit-transformer.bundle.js
files: dist/*
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ include settings.ini
include LICENSE
include CONTRIBUTING.md
include README.md
include squ/atlaskit-transformer.bundle.js
include nbdev_squ/atlaskit-transformer.bundle.js
recursive-exclude * __pycache__
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Below is how to install in a plain python 3.11+ environment

``` sh
pip install https://github.com/wagov/nbdev-squ/archive/refs/tags/v1.3.1.tar.gz
https://github.com/wagov/nbdev-squ/releases/download/v1.3.2/nbdev_squ-1.3.2-py3-none-any.whl
```

The installation can also be run in a notebook (we tend to use
Expand All @@ -18,7 +18,7 @@ should load the json secret *squconfig-`my_keyvault_tenantid`* from the
`my_kevault_name` keyvault.

``` python
%pip install https://github.com/wagov/nbdev-squ/archive/refs/tags/v1.3.1.tar.gz
%pip install https://github.com/wagov/nbdev-squ/releases/download/v1.3.2/nbdev_squ-1.3.2-py3-none-any.whl
import os; os.environ["SQU_CONFIG"] = "{{ my_keyvault_name }}/{{ my_keyvault_tenantid }}"

from nbdev_squ import api
Expand Down
5 changes: 5 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
# Just used during CI to build static assets and add to release
npm install
npm run build
python -m build
6 changes: 5 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#!/bin/bash
# This is meant to be run to setup and prep for committing a release
# use nbdev_bump_version to increment the version itself then rerun this to update README.md etc
pip install nbdev
nbdev_install
npx npm-check-updates -u # convenient way to freshen package.json on each release
npm install
npm run build
nbdev_clean
nbdev_export
nbdev_readme
nbdev_install_hooks

version=$(awk -F' = ' '/^version/{print $2}' settings.ini)
sed -i '' "s/{{ version }}/$version/g" README.md
2 changes: 1 addition & 1 deletion nbdev_squ/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.3.1"
__version__ = "1.3.2"
9 changes: 4 additions & 5 deletions nbdev_squ/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
'atlaskit_transformer', 'security_incidents', 'security_alerts']

# %% ../nbs/01_api.ipynb 3
import pandas, json, logging, time, requests, httpx_cache, io
import pandas, json, logging, time, requests, httpx_cache, io, pkgutil
from importlib.metadata import version
from .core import *
from diskcache import memoize_stampede
from subprocess import run, CalledProcessError
Expand Down Expand Up @@ -237,11 +238,9 @@ def hunt(indicators, expression="has", columns=columns, workspaces=None, timespa

# %% ../nbs/01_api.ipynb 22
def atlaskit_transformer(inputtext, inputfmt="md", outputfmt="wiki", runtime="node"):
import nbdev_squ
transformer = dirs.user_cache_path / f"atlaskit-transformer.bundle_v{nbdev_squ.__version__}.js"
transformer = dirs.user_cache_path / f"atlaskit-transformer.bundle_v{version('nbdev_squ')}.js"
if not transformer.exists():
transformer_url = f'https://github.com/wagov/nbdev-squ/releases/download/v{nbdev_squ.__version__}/atlaskit-transformer.bundle.js'
transformer.write_bytes(requests.get(transformer_url).content)
transformer.write_bytes(pkgutil.get_data("nbdev_squ", "atlaskit-transformer.bundle.js"))
cmd = [runtime, str(transformer), inputfmt, outputfmt]
logger.debug(" ".join(cmd))
try:
Expand Down
9 changes: 4 additions & 5 deletions nbs/01_api.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"outputs": [],
"source": [
"#| export\n",
"import pandas, json, logging, time, requests, httpx_cache, io\n",
"import pandas, json, logging, time, requests, httpx_cache, io, pkgutil\n",
"from importlib.metadata import version\n",
"from nbdev_squ.core import *\n",
"from diskcache import memoize_stampede\n",
"from subprocess import run, CalledProcessError\n",
Expand Down Expand Up @@ -428,11 +429,9 @@
"source": [
"#| exports\n",
"def atlaskit_transformer(inputtext, inputfmt=\"md\", outputfmt=\"wiki\", runtime=\"node\"):\n",
" import nbdev_squ\n",
" transformer = dirs.user_cache_path / f\"atlaskit-transformer.bundle_v{nbdev_squ.__version__}.js\"\n",
" transformer = dirs.user_cache_path / f\"atlaskit-transformer.bundle_v{version('nbdev_squ')}.js\"\n",
" if not transformer.exists():\n",
" transformer_url = f'https://github.com/wagov/nbdev-squ/releases/download/v{nbdev_squ.__version__}/atlaskit-transformer.bundle.js'\n",
" transformer.write_bytes(requests.get(transformer_url).content)\n",
" transformer.write_bytes(pkgutil.get_data(\"nbdev_squ\", \"atlaskit-transformer.bundle.js\"))\n",
" cmd = [runtime, str(transformer), inputfmt, outputfmt]\n",
" logger.debug(\" \".join(cmd))\n",
" try:\n",
Expand Down
7 changes: 5 additions & 2 deletions nbs/index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
"Below is how to install in a plain python 3.11+ environment\n",
"\n",
"```sh\n",
"pip install https://github.com/wagov/nbdev-squ/archive/refs/tags/v1.3.1.tar.gz\n",
"https://github.com/wagov/nbdev-squ/releases/download/v{{ version }}/nbdev_squ-{{ version }}-py3-none-any.whl\n",
"```\n",
"\n",
"The installation can also be run in a notebook (we tend to use [JupyterLab Desktop](https://github.com/jupyterlab/jupyterlab-desktop) for local dev). The `SQU_CONFIG` env var indicates to nbdev_squ it should load the json secret *squconfig-`my_keyvault_tenantid`* from the `my_kevault_name` keyvault.\n",
"\n",
"```python\n",
"%pip install https://github.com/wagov/nbdev-squ/archive/refs/tags/v1.3.1.tar.gz\n",
"%pip install https://github.com/wagov/nbdev-squ/releases/download/v{{ version }}/nbdev_squ-{{ version }}-py3-none-any.whl\n",
"import os; os.environ[\"SQU_CONFIG\"] = \"{{ my_keyvault_name }}/{{ my_keyvault_tenantid }}\" \n",
"\n",
"from nbdev_squ import api\n",
Expand Down Expand Up @@ -201,6 +201,9 @@
"display_name": "python3",
"language": "python",
"name": "python3"
},
"language_info": {
"name": ""
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit c1076db

Please sign in to comment.