Skip to content

Commit

Permalink
Merge pull request #10 from epimorphics/issue/9-change-duration-unit-…
Browse files Browse the repository at this point in the history
…return-type-to-integer

Update duration unit return type to integer
  • Loading branch information
jonrandahl authored Jan 30, 2023
2 parents 434167d + a0c4d00 commit 9f30809
Show file tree
Hide file tree
Showing 14 changed files with 297 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
rubocop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
37 changes: 31 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
# Changelog for DS API rubygem

## 1.3.3- 2023-01

- (Jon) Refactors the elapsed time calculated for API requests to be resolved as
microseconds rather than milliseconds. This is to improve the reporting of the
elapsed time in the system tooling logs.
- (Jon) Resolves failing tests due to the improper invocation of mock objects
without the correct arguments.
- (Jon) Minor text changes to the .gemspec file to update the description and
summary of the gem as well as the name and email address for the maintainer.
- (Jon) Includes multiple updates and fixes to the codebase to resolve the
majority of the Rubocop warnings.
- (Jon) Updated CI/CD workflows to use latest Epimorphics GitHub Actions
versions.
- (Jon) Updated System test to include a test for the new elapsed time metric.
- (Jon) Refactored the linting settings to include lessons learned in other
projects thereby improving the opinionated results from RuboCop to ensure the
codebase adheres to current best practices.
- (Jon) Refactored the version cadence creation to include a SUFFIX value if
provided; otherwise no SUFFIX is included in the version number.
- (Jon) Includes initial steps for better logging of API requests and responses
to the system logs.
- (Jon) As part of the better logging updates the error message returned to the
requesting app has been refactored to be more concise as well the failed
connection error status has been set specifically to `503 Service Unavailable`.

## 1.3.2 - 2022-04-01

- (Ian) Remove use of automated Faraday logging of API calls. Add manual
logging of API calls, to conform to local best practice
- (Ian) Remove use of automated Faraday logging of API calls. Add manual logging
of API calls, to conform to local best practice

## 1.3.1 - 2022-03-28

Expand All @@ -19,8 +44,8 @@

## 1.2.0 - 2022-01-27

- (Ian) Added `ActiveSupport` instrumentation calls to allow collecting
of metrics on API calls
- (Ian) Added `ActiveSupport` instrumentation calls to allow collecting of
metrics on API calls

## 1.1.1 - 2022-01-21

Expand All @@ -32,8 +57,8 @@

## 1.0.0 - 2021-06-14 (Bogdan)

- Added a DSAPI to SapiNT converter, which converts all DSAPI queries
to SapiNT queries and then sends them to a SapiNT backend
- Added a DSAPI to SapiNT converter, which converts all DSAPI queries to SapiNT
queries and then sends them to a SapiNT backend

## 0.4.5 - 2019-11-11

Expand Down
30 changes: 22 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ returned to the caller in a compact JSON format.

In 2021, we took the decision to retire the DsAPI codebase, which has not been
actively maintained for some time. In its place, we now expect to use
[SapiNT](https://github.com/epimorphics/sapi-nt). SapiNT performs a similar
[Sapi-NT](https://github.com/epimorphics/sapi-nt). Sapi-NT performs a similar
function, in that it provides a RESTful API in which compact queries are translated
into SPARQL expressions, and the results are available in (amongst other formats)
JSON encoding. However, the input to SapiNT, in which we articulate the projection
JSON encoding. However, the input to Sapi-NT, in which we articulate the projection
of the underlying hypercube that we require is encoded as URL parameters in an
HTTP GET request. DsAPI, in contrast, expects the input query to be POSTed as a
JSON expression.

To minimise changes to the client applications in which this gem is used, we have
implemented a shim layer that accepts DsAPI expressions and re-codes them as SapiNT
implemented a shim layer that accepts DsAPI expressions and re-codes them as Sapi-NT
URLs. Similarly, differences in the returned JSON results formats are also ironed
out by this shim layer. It is possible to do this because, once the designs of the
applications had settled, the HMLR apps only use a subset of the expressive power
Expand All @@ -50,8 +50,8 @@ source 'https://rubygems.pkg.github.com/epimorphics' do
end
```

An API URL needs to be provided for the `Service` class in order for the gem
to work.
_N.B. An API URL needs to be provided by that project for the `Service` class in
order for the gem to work._

---

Expand All @@ -71,14 +71,25 @@ Inspecting 21 files

### Tests

To run the tests you must set the environment variable `API_URL` to point to a
running instance of a valid SAPINT API and run `rake test`:
You will need to have started the [HMLR Data API](https://github.com/epimorphics/lr-data-api)
locally. To do so follow the instructions in the repository's [README](https://github.com/epimorphics/lr-data-api#run)

Once the API is started you can invoke the tests with the simple command below[^1]:

```sh
rake test
```

You can also set the environment variable `API_URL` to point to a running
instance of the HMLR Data API from a non-default port:

```sh
API_URL=http://localhost:8080 rake test
```

If `API_URL` is not set it will default to `http://localhost:8888`
_N.B If `API_URL` environment variable is not set it will default to `http://localhost:8888`_

---

### Publishing the gem to the GitHub Package Registry

Expand Down Expand Up @@ -113,3 +124,6 @@ This gem integrates with Prometheus monitoring by emitting the following
- `response.api` - API response, including status code and duration
- `connection_failure.api` - failure to connect to the API, with exception detail
- `service_exception.api` - failure to process the API response

[^1]: You may need to preface the `rake test` command with `bundle exec` if you
are using a Ruby version manager such as `rbenv` or `rvm`.
3 changes: 2 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# frozen-string-literal: true
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rake/testtask'

Rake::TestTask.new(:test) do |t|
t.test_files = FileList['test/**/*_test.rb']
t.warning = false
end

task default: :test
7 changes: 4 additions & 3 deletions data_services_api.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen-string-literal: true
# frozen_string_literal: true

lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
Expand All @@ -10,7 +10,8 @@ Gem::Specification.new do |spec|
spec.version = DataServicesApi::VERSION
spec.authors = ['Epimorphics Ltd']
spec.email = ['[email protected]']
spec.summary = 'Ruby wrapper for Epimorphics data service API'
spec.summary = 'Data Services API'
spec.description = 'Ruby wrapper for Epimorphics Data Services API'
spec.homepage = 'https://github.com/epimorphics/data-API-ruby'
spec.license = 'MIT'
spec.required_ruby_version = '>= 2.6'
Expand All @@ -26,7 +27,7 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency 'json', '~> 2.6.1'
spec.add_runtime_dependency 'yajl-ruby', '~> 1.4.1'

spec.add_development_dependency 'bundler', '~> 2.3.5'
spec.add_development_dependency 'bundler', '~> 2.4'
spec.add_development_dependency 'byebug', '~> 11.1.3'
spec.add_development_dependency 'excon', '~> 0.90.0'
spec.add_development_dependency 'json_expressions', '~> 0.9.0'
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/data_services_api/dataset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def describe_api
end

def explain_api
# There should be a HATEOS-style reference to this endpoint
# TODO: There should be a HATEOS-style reference to this endpoint
# https://github.com/epimorphics/ds-api-ruby/issues/1
structure_api.gsub(/structure$/, 'explain')
end
Expand Down
Loading

0 comments on commit 9f30809

Please sign in to comment.