Skip to content

Commit 9021fa3

Browse files
authored
Merge pull request #143 from stared/build-update
Update Python version for GitHub Action builds
2 parents 40c887c + 288ff6f commit 9021fa3

File tree

9 files changed

+46
-40
lines changed

9 files changed

+46
-40
lines changed

.github/workflows/docs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ jobs:
1111
build-and-deploy:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v2
15-
- name: Set up Python 3.7
16-
uses: actions/setup-python@v1
14+
- uses: actions/checkout@v4
15+
- name: Set up Python 3.11
16+
uses: actions/setup-python@v5
1717
with:
18-
python-version: "3.7"
18+
python-version: "3.11"
1919
- name: Install livelossplot with dependencies
2020
run: |
2121
pip install -e .

.github/workflows/external_packages.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ jobs:
1414

1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v4
1818
- name: Set up Python
19-
uses: actions/setup-python@v1
19+
uses: actions/setup-python@v5
2020
with:
21-
python-version: "3.7"
21+
python-version: "3.11"
2222
- name: Install package and dev dependencies
2323
run: |
2424
python -m pip install --upgrade pip

.github/workflows/flake8_yapf.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ jobs:
1111

1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v2
15-
- name: Set up Python 3.7
16-
uses: actions/setup-python@v1
14+
- uses: actions/checkout@v4
15+
- name: Set up Python 3.11
16+
uses: actions/setup-python@v5
1717
with:
18-
python-version: "3.7"
18+
python-version: "3.11"
1919
- name: Install dependencies
2020
run: |
2121
pip install flake8

.github/workflows/pythonpackage.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
python-version: ["3.7", "3.8", "3.9", "3.10"]
18+
python-version: ["3.9", "3.10", "3.11", "3.12"]
1919

2020
steps:
21-
- uses: actions/checkout@v2
21+
- uses: actions/checkout@v4
2222
- name: Set up Python ${{ matrix.python-version }}
23-
uses: actions/setup-python@v1
23+
uses: actions/setup-python@v5
2424
with:
2525
python-version: ${{ matrix.python-version }}
2626
- name: Install dependencies

examples/neptune.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# TO START:
2-
# pip install neptune-client, livelossplot
2+
# pip install neptune, livelossplot
33
# export environment variables
44
# enjoy results
55

@@ -13,22 +13,26 @@
1313

1414

1515
def main():
16-
api_token = os.environ.get('NEPTUNE_API_TOKEN')
17-
project_qualified_name = os.environ.get('NEPTUNE_PROJECT_NAME')
18-
logger = NeptuneLogger(api_token=api_token, project_qualified_name=project_qualified_name)
16+
api_token = os.environ.get("NEPTUNE_API_TOKEN")
17+
project_qualified_name = os.environ.get("NEPTUNE_PROJECT")
18+
logger = NeptuneLogger(
19+
api_token=api_token,
20+
project_qualified_name=project_qualified_name,
21+
tags=["example", "livelossplot"],
22+
)
1923
liveplot = PlotLosses(outputs=[logger])
2024
for i in range(20):
2125
liveplot.update(
2226
{
23-
'accuracy': 1 - np.random.rand() / (i + 2.),
24-
'val_accuracy': 1 - np.random.rand() / (i + 0.5),
25-
'mse': 1. / (i + 2.),
26-
'val_mse': 1. / (i + 0.5)
27+
"accuracy": 1 - np.random.rand() / (i + 2.0),
28+
"val_accuracy": 1 - np.random.rand() / (i + 0.5),
29+
"mse": 1.0 / (i + 2.0),
30+
"val_mse": 1.0 / (i + 0.5),
2731
}
2832
)
2933
liveplot.send()
30-
sleep(.5)
34+
sleep(0.5)
3135

3236

33-
if __name__ == '__main__':
37+
if __name__ == "__main__":
3438
main()

livelossplot/outputs/neptune_logger.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ def __init__(self, api_token: Optional[str] = None, project_qualified_name: Opti
1515
**kwargs: keyword args, that will be passed to create_experiment function
1616
"""
1717
import neptune
18+
1819
self.neptune = neptune
19-
self.neptune.init(api_token=api_token, project_qualified_name=project_qualified_name)
20-
self.experiment = self.neptune.create_experiment(**kwargs)
20+
self.run = self.neptune.init_run(api_token=api_token, project=project_qualified_name, **kwargs)
2121

2222
def close(self):
2323
"""Close connection"""
24-
self.neptune.stop()
24+
if hasattr(self, "run"):
25+
self.run.stop()
2526

2627
def send(self, logger: MainLogger):
2728
"""Send metrics collected in last step to neptune server"""
2829
for name, log_items in logger.log_history.items():
2930
last_log_item = log_items[-1]
30-
self.neptune.send_metric(name, x=last_log_item.step, y=last_log_item.value)
31+
self.run[name].append(value=last_log_item.value, step=last_log_item.step)

livelossplot/plot_losses.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ class PlotLosses:
1313
"""
1414
Class collect metrics from the training engine and send it to plugins, when send is called
1515
"""
16-
1716
def __init__(
1817
self,
1918
outputs: List[Union[Type[BO], str]] = ['MatplotlibPlot', 'ExtremaPrinter'],

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ def version():
5050
'Programming Language :: Python :: 3.8',
5151
'Programming Language :: Python :: 3.9',
5252
'Programming Language :: Python :: 3.10',
53+
'Programming Language :: Python :: 3.11',
54+
'Programming Language :: Python :: 3.12',
5355
],
5456
packages=find_packages(),
5557
zip_safe=False

tests/external_api_test_neptune.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,31 @@
88

99
def test_neptune():
1010
neptune_logger = NeptuneLogger(
11-
api_token="ANONYMOUS", project_qualified_name="shared/colab-test-run", tags=['livelossplot', 'github-actions']
11+
api_token="ANONYMOUS",
12+
project_qualified_name="shared/colab-test-run",
13+
tags=["livelossplot", "github-actions"],
1214
)
1315

1416
plotlosses = PlotLosses(outputs=[neptune_logger])
1517

16-
assert neptune_logger.experiment.state == 'running'
18+
assert neptune_logger.run.exists
1719

1820
for i in range(3):
1921
plotlosses.update(
2022
{
21-
'acc': 1 - np.random.rand() / (i + 2.),
22-
'val_acc': 1 - np.random.rand() / (i + 0.5),
23-
'loss': 1. / (i + 2.),
24-
'val_loss': 1. / (i + 0.5)
23+
"acc": 1 - np.random.rand() / (i + 2.0),
24+
"val_acc": 1 - np.random.rand() / (i + 0.5),
25+
"loss": 1.0 / (i + 2.0),
26+
"val_loss": 1.0 / (i + 0.5),
2527
}
2628
)
2729
plotlosses.send()
2830

29-
assert neptune_logger.experiment.state == 'running'
31+
assert neptune_logger.run.exists
3032

3133
neptune_logger.close()
3234

33-
# This is not working anymore.
34-
# assert neptune_logger.experiment.state == 'succeeded'
35-
36-
url = neptune.project._get_experiment_link(neptune_logger.experiment)
35+
# Get the run URL
36+
url = neptune_logger.run.get_url()
3737

3838
assert len(url) > 0

0 commit comments

Comments
 (0)