Closed keighrim closed 1 year ago
Regarding the question number 2 from the previous comment, implementation of app_version
injection that's proposed in https://github.com/clamsproject/clams-python/pull/118 is done basically by setting a default value (default but dynamically generated) to the field before _appmetadata()
, appmetadata()
, or metadata.{jons,py}
. So the question seems to have become irrelevant. However it may come back for a future development (addition, change) of a field in AppMetadata that needs automatic generation but cannot use a "default_factory"-like mechanism. (I can't imagine such an example for now though)
Additionally, with some fields are being auto-generated (currently mmif_version
, possibly app_version
and identifier
in the future depending on how #114 resolves), I actually don't think having static JSON/YAML files is a good option anymore. Conceptually, if there's metadata.py
I would immediately think that there should be something dynamically generated, but when I see a JSON or YAML file, I'd take the file as static information and consider what in there is a complete set of necessary information. However, with auto-generating values, a static JSON/YAML file cannot be a complete, source-of-truth file, unless the maintainer takes extreme care of the content not to be outdated, which I would not expect from any human being.
resolved via #128 .
As we march toward the development of prototype of the app-directory (https://github.com/clamsproject/clams-apps/issues/15), it seems that we need a easier way to query for app metadata. In the linked issue, there were two suggestions on how a machine can read app metadata.
And @kelleyl and I talked about this last week, and we'd like to suggest a third way. But first, possible issues with the above suggestions;
So the third way;
App development side
Developers can choose between
metadata.json
ormetadata.py
to write the app metadata.metadata.json
(or yaml): this is identical to the first suggestion above. If a developer is confident in directly editing raw JSON file and makes sure the file is valid JSON as well as CLAMS app metadata, they should be able to choose this path and not worry about writing more python code as described in the below.metadata.py
: we provide a skeleton for this file via the SDK documentation or the template code repository. This file MUST import only python builtins andclams-python
library to minimize time and effort to build and run this file.SDK development side
And then in the SDK, we remove
_appmetadata()
method and re-writeannotate()
so thatmetadata.json
is present, just load the metadata from the file.metadata.py
is present, import the module and call a function inside to load metadata.App template
And, the
metadata.py
in the starter kit should look like;app-directory
side storyAnd finally, but not the least, app directory automation can
metadata.json
is present, just read the file inmetadata.py
is present, runpip install $(grep clams-python requirements.txt); python metadata.py > metadata.json
and read in the json fileA few question to resolve to make this happen:
metadata.py
template? If we do so, then when there's an update in the metadata scheme, we need to update two different codebase. I think that's probably not the best practice. We can maybe package the whole template repository inside the SDK and add a CLI command (likeclams new-app
) to release a local copy of the template on demand.appmetadata()
method, the output ofmetadata.py
(and the app-directory) won't have those to-be-injected fieldsmetadata.py
, it is no longer a part of SDK. In this case, if there'smetadata.json
instead of themetadata.py
, the app-directory, again, won't have those to-be-injected fields.clams app-metadata
) to collect information from the working directory (metadata.json
,metadata.py
,git log
,$APP_VERSION
, etc) and generate a complete metadata JSON.Now I'm all ears. Let me know what you think.