Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v1
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.7"
python-version: "3.11"
- name: Install livelossplot with dependencies
run: |
pip install -e .
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/external_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: "3.7"
python-version: "3.11"
- name: Install package and dev dependencies
run: |
python -m pip install --upgrade pip
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/flake8_yapf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v1
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.7"
python-version: "3.11"
- name: Install dependencies
run: |
pip install flake8
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
24 changes: 14 additions & 10 deletions examples/neptune.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# TO START:
# pip install neptune-client, livelossplot
# pip install neptune, livelossplot
# export environment variables
# enjoy results

Expand All @@ -13,22 +13,26 @@


def main():
api_token = os.environ.get('NEPTUNE_API_TOKEN')
project_qualified_name = os.environ.get('NEPTUNE_PROJECT_NAME')
logger = NeptuneLogger(api_token=api_token, project_qualified_name=project_qualified_name)
api_token = os.environ.get("NEPTUNE_API_TOKEN")
project_qualified_name = os.environ.get("NEPTUNE_PROJECT")
logger = NeptuneLogger(
api_token=api_token,
project_qualified_name=project_qualified_name,
tags=["example", "livelossplot"],
)
liveplot = PlotLosses(outputs=[logger])
for i in range(20):
liveplot.update(
{
'accuracy': 1 - np.random.rand() / (i + 2.),
'val_accuracy': 1 - np.random.rand() / (i + 0.5),
'mse': 1. / (i + 2.),
'val_mse': 1. / (i + 0.5)
"accuracy": 1 - np.random.rand() / (i + 2.0),
"val_accuracy": 1 - np.random.rand() / (i + 0.5),
"mse": 1.0 / (i + 2.0),
"val_mse": 1.0 / (i + 0.5),
}
)
liveplot.send()
sleep(.5)
sleep(0.5)


if __name__ == '__main__':
if __name__ == "__main__":
main()
9 changes: 5 additions & 4 deletions livelossplot/outputs/neptune_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ def __init__(self, api_token: Optional[str] = None, project_qualified_name: Opti
**kwargs: keyword args, that will be passed to create_experiment function
"""
import neptune

self.neptune = neptune
self.neptune.init(api_token=api_token, project_qualified_name=project_qualified_name)
self.experiment = self.neptune.create_experiment(**kwargs)
self.run = self.neptune.init_run(api_token=api_token, project=project_qualified_name, **kwargs)

def close(self):
"""Close connection"""
self.neptune.stop()
if hasattr(self, "run"):
self.run.stop()

def send(self, logger: MainLogger):
"""Send metrics collected in last step to neptune server"""
for name, log_items in logger.log_history.items():
last_log_item = log_items[-1]
self.neptune.send_metric(name, x=last_log_item.step, y=last_log_item.value)
self.run[name].append(value=last_log_item.value, step=last_log_item.step)
1 change: 0 additions & 1 deletion livelossplot/plot_losses.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class PlotLosses:
"""
Class collect metrics from the training engine and send it to plugins, when send is called
"""

def __init__(
self,
outputs: List[Union[Type[BO], str]] = ['MatplotlibPlot', 'ExtremaPrinter'],
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def version():
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
],
packages=find_packages(),
zip_safe=False
Expand Down
22 changes: 11 additions & 11 deletions tests/external_api_test_neptune.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@

def test_neptune():
neptune_logger = NeptuneLogger(
api_token="ANONYMOUS", project_qualified_name="shared/colab-test-run", tags=['livelossplot', 'github-actions']
api_token="ANONYMOUS",
project_qualified_name="shared/colab-test-run",
tags=["livelossplot", "github-actions"],
)

plotlosses = PlotLosses(outputs=[neptune_logger])

assert neptune_logger.experiment.state == 'running'
assert neptune_logger.run.exists

for i in range(3):
plotlosses.update(
{
'acc': 1 - np.random.rand() / (i + 2.),
'val_acc': 1 - np.random.rand() / (i + 0.5),
'loss': 1. / (i + 2.),
'val_loss': 1. / (i + 0.5)
"acc": 1 - np.random.rand() / (i + 2.0),
"val_acc": 1 - np.random.rand() / (i + 0.5),
"loss": 1.0 / (i + 2.0),
"val_loss": 1.0 / (i + 0.5),
}
)
plotlosses.send()

assert neptune_logger.experiment.state == 'running'
assert neptune_logger.run.exists

neptune_logger.close()

# This is not working anymore.
# assert neptune_logger.experiment.state == 'succeeded'

url = neptune.project._get_experiment_link(neptune_logger.experiment)
# Get the run URL
url = neptune_logger.run.get_url()

assert len(url) > 0
Loading