Repository: scikit-hep/pyhf

Issue:
Workspace.version is not set when loading in a workspace with a version
# Description

See the title.

# Expected Behavior

`Workspace.version is not None`

# Actual Behavior

`Workspace.version is None`

# Steps to Reproduce

```python
import pyhf, json

ws = pyhf.Workspace(json.load(open('workspace.json')))
assert ws.version is not None
assert ws.version == ws['version']
```

# Checklist

- [x] Run `git fetch` to get the most up to date version of `master`
- [x] Searched through existing Issues to confirm this is not a duplicate issue
- [x] Filled out the Description, Expected Behavior, Actual Behavior, and Steps to Reproduce sections above or have edited/removed them in a way that fully describes the issue



Discussion:
I am now moving on to this issue but I'm unable to reproduce the error due to the following exception raised in the workspace.py file
```
KeyError: 'channels' 
```
which is due to as per the workspace.json file 
```
Unable to load schema from 'http://json-schema.org/draft-06/schema'. No schema request service available(768)
```

I am afraid that I couldn't find a solution to the above problem.
@kanishk16 , not sure how you're getting that error...

```
>>> import pyhf, json
>>> ws = pyhf.Workspace(json.load(open('my-workspace.json')))
>>> ws.version
>>> ws['version']
'1.0.0'
```

works for me just fine. Are you trying to load in the `pyhf/schemas/1.0.0/workspace.json` file as a workspace? It's a schema describing a workspace, not a workspace itself.
Sorry for the late reply @kratsg ...Yes, I was trying to load `pyhf/schemas/1.0.0/workspace.json`. Since I am using Google Colab, I am not sure if there already exists a workspace.json.
I might not be well versed about it. From what I know, not sure if you are talking about this, there exists a workspace.json corresponding to the workspace of each user. But, what if the workspace.json doesn't exist only (never really thought of)? Could you point me to some resources if I am heading in the wrong direction? 
There are published likelihoods available for usage here: https://scikit-hep.org/pyhf/citations.html#published-likelihoods - e.g.

```
curl -s -- https://www.hepdata.net/record/resource/1165724?view=true |tar -O -xzvf - - --include patch.ERJR_350p0_0p0.json > patch.ERJR_350p0_0p0.json
curl -s -- https://www.hepdata.net/record/resource/1165724?view=true |tar -O -xzvf - - --include BkgOnly.json > BkgOnly.json
jsonpatch BkgOnly.json patch.ERJR_350p0_0p0.json > my_workspace.json
```

to get an example workspace in practice. The `workspace.json` is just a schema. You should understand the difference between a JSON schema specification and a JSON document that follows the schema.

Resolving patch:
diff --git a/src/pyhf/workspace.py b/src/pyhf/workspace.py
--- a/src/pyhf/workspace.py
+++ b/src/pyhf/workspace.py
@@ -267,9 +267,10 @@ def __init__(self, spec, **config_kwargs):
         """Workspaces hold the model, data and measurements."""
         super(Workspace, self).__init__(spec, channels=spec['channels'])
         self.schema = config_kwargs.pop('schema', 'workspace.json')
-        self.version = config_kwargs.pop('version', None)
+        self.version = config_kwargs.pop('version', spec.get('version', None))
+
         # run jsonschema validation of input specification against the (provided) schema
-        log.info("Validating spec against schema: {0:s}".format(self.schema))
+        log.info(f"Validating spec against schema: {self.schema}")
         utils.validate(self, self.schema, version=self.version)
 
         self.measurement_names = []


Test patch:
diff --git a/tests/test_workspace.py b/tests/test_workspace.py
--- a/tests/test_workspace.py
+++ b/tests/test_workspace.py
@@ -38,6 +38,11 @@ def test_build_workspace(workspace_factory):
     assert w
 
 
+def test_version_workspace(workspace_factory):
+    ws = workspace_factory()
+    assert ws.version is not None
+
+
 def test_build_model(workspace_factory):
     w = workspace_factory()
     assert w.model()