Skip to content

Commit b3dc479

Browse files
committed
Fixing CI pipeline, generating image for artifact testing, and generalizing ENVs in tests
1 parent ebfcaee commit b3dc479

File tree

7 files changed

+48
-59
lines changed

7 files changed

+48
-59
lines changed

.github/workflows/CI.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,27 @@ jobs:
2222
- x64
2323
steps:
2424
- uses: actions/checkout@v2
25-
- name: Start services
26-
run: docker-compose -f docker compose.test.yaml up -d
27-
# - name: Setup custom python requirements
28-
# if: hashFiles('**/requirements.txt', '**/pyproject.toml') == ''
29-
# run: |
30-
# touch ./requirements.txt
31-
# echo "mlflow[auth]==3.2.0" > ./requirements.txt
32-
# - uses: actions/setup-python@v4
33-
# with:
34-
# python-version: '3.12.3'
35-
# cache: 'pip'
36-
# - name: Setup mlflow locally
37-
# run: |
38-
# export MLFLOW_FLASK_SERVER_SECRET_KEY='mlflowclient.jl'
39-
# pip install -r ./requirements.txt
40-
# python3 /opt/hostedtoolcache/Python/3.12.3/x64/bin/mlflow server --app-name basic-auth --host 0.0.0.0 --port 5000 &
41-
# sleep 5
25+
- name: Setup custom python requirements
26+
if: hashFiles('**/requirements.txt', '**/pyproject.toml') == ''
27+
run: |
28+
touch ./requirements.txt
29+
echo "mlflow[auth]==3.6.0" > ./requirements.txt
30+
- uses: actions/setup-python@v4
31+
with:
32+
python-version: '3.12.3'
33+
cache: 'pip'
34+
- uses: infleet/[email protected]
35+
with:
36+
port: "9000"
37+
version: "latest"
38+
username: "minioadmin"
39+
password: "minioadmin"
40+
- name: Setup mlflow locally
41+
run: |
42+
export MLFLOW_FLASK_SERVER_SECRET_KEY='mlflowclient.jl'
43+
pip install -r ./requirements.txt
44+
python3 /opt/hostedtoolcache/Python/3.12.3/x64/bin/mlflow server --app-name basic-auth --host 0.0.0.0 --port 5000 &
45+
sleep 5
4246
- uses: julia-actions/setup-julia@v1
4347
with:
4448
version: ${{ matrix.version }}
@@ -57,10 +61,6 @@ jobs:
5761
- uses: julia-actions/julia-runtest@v1
5862
env:
5963
JULIA_NUM_THREADS: '1'
60-
MLFLOW_TRACKING_URI: "http://localhost:5050/api"
61-
MLFLOW_S3_ENDPOINT_URL: "http://minio:9000"
62-
AWS_ACCESS_KEY_ID: minioadmin
63-
AWS_SECRET_ACCESS_KEY: minioadmin
6464
- uses: julia-actions/julia-processcoverage@v1
6565
- uses: codecov/codecov-action@v3
6666
with:

Project.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MLFlowClient"
22
uuid = "64a0f543-368b-4a9a-827a-e71edb2a0b83"
3-
authors = ["@deyandyankov, @pebeto, and contributors"]
43
version = "0.7.0"
4+
authors = ["@deyandyankov, @pebeto, and contributors"]
55

66
[deps]
77
AWSS3 = "1c724243-ef5b-51ab-93f4-b0a88ac62a95"
@@ -22,13 +22,15 @@ FileTypes = "0.1.1"
2222
HTTP = "1.0"
2323
JSON = "0.21"
2424
Minio = "0.2.2"
25+
Plots = "1.41.2"
2526
ShowCases = "0.1"
2627
URIs = "1.0"
2728
julia = "1.0"
2829

2930
[extras]
3031
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
3132
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
33+
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
3234

3335
[targets]
34-
test = ["Base64", "Test"]
36+
test = ["Base64", "Plots", "Test"]

test/assets/julia.png

-82.5 KB
Binary file not shown.

test/base.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Test
22
using Dates
33
using HTTP
4+
using Plots
45
using UUIDs
56
using Base64
67
using MLFlowClient
@@ -18,8 +19,8 @@ using URIs
1819
Check MLFlow health endpoint. Return true if healthy, false otherwise.
1920
"""
2021
function mlflow_server_is_running()
21-
resp = HTTP.request("HEAD", "$(TEST_MLFLOW_URI)/health", readtimeout=10)
22-
return resp.status == 200
22+
resp = HTTP.request("HEAD", "http://127.0.0.1:5050/health", readtimeout=10)
23+
return resp.status == 200
2324
end
2425

2526
# creates an instance of mlf
@@ -40,7 +41,11 @@ end
4041
Check minio health endpoint. Return true if health, false otherwise
4142
"""
4243
function minio_is_running()
43-
response = HTTP.request("HEAD", "$(TEST_MLFLOW_S3_ENDPOINT_URL)/minio/health/live", readtimeout=10)
44+
response = HTTP.request(
45+
"HEAD",
46+
"http://127.0.0.1:9000/minio/health/live",
47+
readtimeout=10,
48+
)
4449
return response.status == 200
4550
end
4651

test/runtests.jl

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,15 @@
1-
if ~haskey(ENV, "MLFLOW_TRACKING_URI")
2-
error("""WARNING: MLFLOW_TRACKING_URI is not set.
3-
To run the unit tests, you need to set the URI of your MLFlow server API.
4-
5-
A test environment is provided in .devcontainers/compose.yaml, start it as
6-
`docker-compose .devcontainers/compose.yaml up`.
7-
8-
Then set the environment variables
9-
MLFLOW_TRACKING_URI="http://localhost:5050/api"
10-
AWS_ACCESS_KEY_ID="minioadmin"
11-
AWS_SECRET_ACCESS_KEY="minioadmin"
12-
MLFLOW_S3_ENDPOINT_URL="http://localhost:9000"
13-
""")
14-
end
15-
16-
17-
# Set up access to testing environment defined in docker-compose.test.yaml
18-
const TEST_MLFLOW_URI = "http://localhost:5050/"
19-
const TEST_MLFLOW_TRACKING_URI = "http://127.0.0.1:5050/api"
20-
const TEST_MLFLOW_S3_ENDPOINT_URL = get(ENV, "MLFLOW_S3_ENDPOINT_URL", "http://127.0.0.1:9000")
21-
const TEST_AWS_ACCESS_KEY_ID = get(ENV, "AWS_ACCESS_KEY_ID", "minioadmin")
22-
const TEST_AWS_SECRET_ACCESS_KEY = get(ENV, "AWS_SECRET_ACCESS_KEY", "minioadmin")
23-
24-
1+
@warn "To run this test suite, ensure to run `docker-compose -f docker-compose.test.yml up`"
252

3+
ENV["GKSwstype"]="nul" # to disable plotting windows during tests
4+
ENV["MLFLOW_TRACKING_URI"] = "http://127.0.0.1:5050/api"
265

276
include("base.jl")
287

29-
const minio_cfg = MinioConfig(TEST_MLFLOW_S3_ENDPOINT_URL; username=TEST_AWS_ACCESS_KEY_ID, password=TEST_AWS_SECRET_ACCESS_KEY)
8+
const minio_cfg = MinioConfig(
9+
"http://127.0.0.1:9000";
10+
username="minioadmin",
11+
password="minioadmin",
12+
)
3013
include("setup.jl")
3114

3215
include("types/mlflow.jl")

test/services/logger.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,8 @@ end
348348
write(fp, dummy_content)
349349
end
350350

351-
image_file_path = joinpath("test", "assets", "julia.png")
351+
image_file_path = "fig.png"
352+
savefig(plot(rand(10), rand(10)), image_file_path)
352353

353354
@testset "upload new artifact" begin
354355
experiment_id = createexperiment(mlf, "test-experiment-logartifact")
@@ -396,10 +397,10 @@ end
396397
experiment_id = createexperiment(mlf, "test-experiment-logartifact-3")
397398
run = createrun(mlf, experiment_id)
398399

399-
@test logartifact(minio_cfg, run, image_file_path, "julia.png")
400+
@test logartifact(minio_cfg, run, image_file_path, "fig.png")
400401
u = URI(run.info.artifact_uri)
401402
bucket_name = u.host
402-
artifact_path = joinpath(u.path[2:end], "julia.png")
403+
artifact_path = joinpath(u.path[2:end], "fig.png")
403404

404405
# verify upload
405406
downloaded_content = s3_get(minio_cfg, bucket_name, artifact_path)
@@ -410,6 +411,7 @@ end
410411
end
411412

412413
rm(dummy_file_path)
414+
rm(image_file_path)
413415
end
414416
end
415417

test/setup.jl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
# Test if MLFlow and Minio are running (see .devcontainers/compose.yaml)
22

33
@testset verbose = true "infrastructure" begin
4-
println("Testing if MLFlow is running")
5-
64
mlflow_up = try
75
mlflow_server_is_running()
86
catch
97
false
108
end
11-
mlflow_up || @error "The MLFlow test instance is not running. Please start it as `docker-compose -f .devcontainers/compose.yaml -up"
9+
mlflow_up || @error "The MLFlow test instance is not running."
1210

1311
@test mlflow_up
14-
println("Testing if Minio is running")
1512

1613
minio_up = try
1714
minio_is_running()
1815
catch
1916
false
2017
end
2118

22-
minio_up || @error "The Minio test instance is not running. Please start the test environment as `docker-compose -f .devcontainers/compose.yaml up`"
19+
minio_up || @error "The MiniO test instance is not running."
2320

2421
@test minio_up
2522
end

0 commit comments

Comments
 (0)