Update artifactory backend to use REST API#293
Draft
hagenw wants to merge 23 commits into
Draft
Conversation
Contributor
Reviewer's GuideReplaces the Artifactory backend’s dohq-artifactory dependency with a thin requests-based REST client while preserving the public Artifactory API, adjusts authentication/config loading and test cleanup, and adds a reusable benchmark suite plus recorded baseline results for validating performance of the new implementation. Sequence diagram for REST-based file download with progresssequenceDiagram
actor Developer
participant BenchmarkScript
participant ArtifactoryBackend as Artifactory
participant RestClient as ArtifactoryRestClient
participant ArtifactoryServer
Developer->>BenchmarkScript: run benchmark_artifactory_main()
BenchmarkScript->>ArtifactoryBackend: get_file(src_path, dst_path, num_workers)
activate ArtifactoryBackend
ArtifactoryBackend->>ArtifactoryBackend: _get_file(src_path, dst_path, verbose)
ArtifactoryBackend->>DownloadHelper: _download_with_progress(_client, src_path, dst_path, verbose)
activate DownloadHelper
DownloadHelper->>RestClient: stat(src_path)
activate RestClient
RestClient->>ArtifactoryServer: GET /api/storage/{repo}/{path}
ArtifactoryServer-->>RestClient: 200 size, checksums, mtime, owner
RestClient-->>DownloadHelper: metadata dict
DownloadHelper->>DownloadHelper: create progress_bar(total=size)
loop stream chunks
DownloadHelper->>RestClient: download(src_path, dst_path, on_chunk=pbar.update)
RestClient->>ArtifactoryServer: GET /{repo}/{path} (stream)
ArtifactoryServer-->>RestClient: chunk bytes
RestClient-->>DownloadHelper: on_chunk(len)
DownloadHelper->>DownloadHelper: pbar.update(len)
end
deactivate RestClient
deactivate DownloadHelper
ArtifactoryBackend-->>BenchmarkScript: return
deactivate ArtifactoryBackend
Class diagram for Artifactory backend using REST clientclassDiagram
class Artifactory {
- str host
- str repository
- tuple authentication
- ArtifactoryRestClient _client
- requests_Session _session
+ Artifactory(str host, str repository, tuple authentication)
+ get_authentication(str host) tuple
+ path(str path) str
- _open()
- _close()
- _checksum(str path) str
- _date(str path) str
- _exists(str path) bool
- _size(str path) int
- _ls(str path) list~str~
- _get_file(str src_path, str dst_path, bool verbose)
- _get_file_stream(str src_path) Iterator~bytes~
- _put_file(str src_path, str dst_path, str checksum, bool verbose)
- _copy_file(str src_path, str dst_path, bool verbose)
- _move_file(str src_path, str dst_path, bool verbose)
- _remove_file(str path)
- _create()
- _delete()
- _owner(str path) str
}
class ArtifactoryRestClient {
- str host
- str repository
- requests_Session session
+ ArtifactoryRestClient(str host, str repository, requests_Session session)
+ stat(str path) dict
+ exists(str path) bool
+ download(str path, str dst_path, int chunk_size, on_chunk)
+ stream(str path, int chunk_size) Iterator~bytes~
+ upload(str src_path, str dst_path, str md5)
+ delete(str path)
+ copy(str src_path, str dst_path)
+ move(str src_path, str dst_path)
+ list_files(str sub_path) list~str~
+ repository_exists() bool
+ create_repository(str package_type)
+ delete_repository()
- _file_url(str path) str
- _storage_url(str path) str
- _repo_url() str
- _copy_or_move(str action, str src_path, str dst_path)
}
class DownloadHelpers {
+ _download_with_progress(ArtifactoryRestClient client, str src_path, str dst_path, bool verbose)
}
class ConfigHelpers {
+ _find_config_entry(configparser_ConfigParser config, str host) dict
}
Artifactory --> ArtifactoryRestClient : uses
DownloadHelpers --> ArtifactoryRestClient : calls
Artifactory ..> DownloadHelpers : uses
Artifactory ..> ConfigHelpers : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
🚀 New features to boost your workflow:
|
This reverts commit b361155.
af5fed3 to
59bc97a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes
dohq-artifactoryas dependency and uses the REST API of Artifactory instead.It introduces two breaking changes:
audbackend.backend.Artifactory.path()now returns a string (as the other backends) and no longer anartifaactory.ArtifactoryPathobjectaudbackend[artifactory]is no longer availableBesides making sure that we still have the same functionality (by the unit tests), we also compare execution time to see we do not regress with the new implementation: