问:
spark.read.json error: (java.lang.ArrayStoreException: java.util.HashMap)
I'm using the code below to pull in multiple json files into 1 using pagination. When I try to create a spark dataframe I get the error '
java.lang.ArrayStoreException: java.util.HashMap' during spark.read.json. Below the code block I've provided output from printing the 'issues' data set (minus proprietary info). I've done a bit of research and can't figure out what I can try to make this work. Any assistance would be greatly appreciated!!

```<code>import requests
import json

limit = 2
startat = 0
issues = []

for page_num in range(2):
    startat = page_num*50
    url = f"https://URL/rest/api/2/search?jql=TEST&startAt={startat}&maxResults={limit}"
    req = requests.get(url, headers={'Accept': 'application/json', 'Authorization': 'Basic xxxxxxxxxxxxxxxxxxxxxxxxxx'})
    data = req.json()
    issues.extend(data['issues'])

jsonDF = spark.read.json(issues)
jsonDF.printSchema()
</code>```

[{'expand': 'operations,versionedRepresentations,editmeta,changelog,customfield_10010.requestTypePractice,renderedFields', 'id': '11441', 'self': 'https://my.url.net/rest/api/2/issue/11441', 'key': 'TS-1401', 'fields': {'statuscategorychangedate': '2022-11-29T07:05:17.359-0800', 'issuetype': {'self': 'https://my.url.net/rest/api/2/issuetype/10004', 'id': '10004', 'description': 'Functionality or a feature expressed as a user goal.', 'iconUrl': 'https://my.url.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10315?size=medium', 'name': 'Story', 'subtask': False, 'avatarId': 10315, 'hierarchyLevel': 0}, 'parent': {'id': '11420', 'key': 'TS-1380', 'self': 'https://my.url.net/rest/api/2/issue/11420', 'fields': {'summary': 'Clone30 - Migration Epics', 'status': {'self': 'https://my.url.net/rest/api/2/status/10003', 'description': '', 'iconUrl': 'https://my.url.net/', 'name': 'Backlog', 'id': '10003', 'statusCategory': {'self': 'https://my.url.net/rest/api/2/statuscategory/2', 'id': 2, 'key': 'new', 'colorName': 'blue-gray', 'name': 'To Do'}}, 'priority': {'self': 'https://my.url.net/rest/api/2/priority/3', 'iconUrl': 'https://my.url.net/images/icons/priorities/medium.svg', 'name': 'Medium', 'id': '3'}, 'issuetype': {'self': 'https://my.url.net/rest/api/2/issuetype/10000', 'id': '10000', 'description': 'A big user story that needs to be broken down. Created by Jira Software - do not edit or delete.', 'iconUrl': 'https://my.url.net/images/icons/issuetypes/epic.svg', 'name': 'Epic', 'subtask': False, 'hierarchyLevel': 1}}}, 'timespent': None, 'project': {'self': 'https://my.url.net/rest/api/2/project/10001', 'id': '10001', 'key': 'TS', 'name': 'Project', 'projectTypeKey': 'software', 'simplified': False, 'avatarUrls': {'48x48': 'https://my.url.net/rest/api/2/universal_avatar/view/type/project/avatar/10556', '24x24': 'https://my.url.net/rest/api/2/universal_avatar/view/type/project/avatar/10556?size=small', '16x16': 'https://my.url.net/rest/api/2/universal_avatar/view/type/project/avatar/10556?size=xsmall', '32x32': 'https://my.url.net/rest/api/2/universal_avatar/view/type/project/avatar/10556?size=medium'}}, 'customfield_10033': None, 'fixVersions': [], 'aggregatetimespent': None, 'customfield_10034': [], 'customfield_10035': None, 'resolution': None, 'customfield_10036': None, 'customfield_10037': None, 'customfield_10027': None, 'customfield_10028': None, 'customfield_10029': None, 'resolutiondate': None, 'workratio': -1, 'watches': {'self': 'https://my.url.net/rest/api/2/issue/TS-1401/watchers', 'watchCount': 1, 'isWatching': True}, 'lastViewed': '2022-12-08T10:06:57.022-0800', 'created': '2022-11-29T07:05:16.501-0800', 'customfield_10020': None, 'customfield_10021': None, 'customfield_10022': None, 'priority': {'self': 'https://my.url.net/rest/api/2/priority/3', 'iconUrl': 'https://my.url.net/images/icons/priorities/medium.svg', 'name': 'Medium', 'id': '3'}, 'customfield_10023': None, 'customfield_10024': None, 'customfield_10025': None, 'customfield_10026': None, 'labels': [], 'customfield_10016': None, 'customfield_10017': None, 'customfield_10018': {'hasEpicLinkFieldDependency': False, 'showField': False, 'nonEditableReason': {'reason': 'EPIC_LINK_SHOULD_BE_USED', 'message': 'To set an epic as the parent, use the epic link instead'}}, 'customfield_10019': '0|i008a3:', 'timeestimate': None, 'aggregatetimeoriginalestimate': None, 'versions': [], 'issuelinks': [], 'assignee': None, 'updated': '2022-11-29T07:05:20.759-0800', 'status': {'self': 'https://my.url.net/rest/api/2/status/10003', 'description': '', 'iconUrl': 'https://my.url.net/', 'name': 'Backlog', 'id': '10003', 'statusCategory': {'self': 'https://my.url.net/rest/api/2/statuscategory/2', 'id': 2, 'key': 'new', 'colorName': 'blue-gray', 'name': 'To Do'}}, 'components': [], 'timeoriginalestimate': None, 'description': 'Data owner completes template (understand scope of migration efforts)', 'customfield_10010': None, 'customfield_10014': 'TS-1380', 'customfield_10015': None, 'customfield_10005': None, 'customfield_10006': None, 'customfield_10007': None, 'security': None, 'customfield_10008': None, 'customfield_10009': None, 'aggregatetimeestimate': None, 'summary': 'Template', 'creator': {'self': 'https://my.url.net/rest/api/2/user?accountId=5d669f4bf81f2c0d99ee9e38', 'accountId': '5d669f4bf81f2c0d99ee9e38', 'emailAddress': 'test@aol.com', 'avatarUrls': {'48x48': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '24x24': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '16x16': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '32x32': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png'}, 'displayName': 'Joe Test', 'active': True, 'timeZone': 'America/Los_Angeles', 'accountType': 'atlassian'}, 'subtasks': [{'id': '11442', 'key': 'TS-1402', 'self': 'https://my.url.net/rest/api/2/issue/11442', 'fields': {'summary': 'Complete Template with table/views required (in) and produced (out)', 'status': {'self': 'https://my.url.net/rest/api/2/status/10003', 'description': '', 'iconUrl': 'https://my.url.net/', 'name': 'Backlog', 'id': '10003', 'statusCategory': {'self': 'https://my.url.net/rest/api/2/statuscategory/2', 'id': 2, 'key': 'new', 'colorName': 'blue-gray', 'name': 'To Do'}}, 'priority': {'self': 'https://my.url.net/rest/api/2/priority/3', 'iconUrl': 'https://my.url.net/images/icons/priorities/medium.svg', 'name': 'Medium', 'id': '3'}, 'issuetype': {'self': 'https://my.url.net/rest/api/2/issuetype/10006', 'id': '10006', 'description': "A small piece of work that's part of a larger task.", 'iconUrl': 'https://my.url.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10316?size=medium', 'name': 'Sub-task', 'subtask': True, 'avatarId': 10316, 'hierarchyLevel': -1}}}], 'reporter': {'self': 'https://my.url.net/rest/api/2/user?accountId=5d669f4bf81f2c0d99ee9e38', 'accountId': '5d669f4bf81f2c0d99ee9e38', 'emailAddress': 'test@aol.com', 'avatarUrls': {'48x48': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '24x24': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '16x16': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '32x32': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png'}, 'displayName': 'Joe Test', 'active': True, 'timeZone': 'America/Los_Angeles', 'accountType': 'atlassian'}, 'aggregateprogress': {'progress': 0, 'total': 0}, 'customfield_10001': None, 'customfield_10002': None, 'customfield_10003': None, 'customfield_10004': None, 'customfield_10038': None, 'environment': None, 'duedate': None, 'progress': {'progress': 0, 'total': 0}, 'votes': {'self': 'https://my.url.net/rest/api/2/issue/TS-1401/votes', 'votes': 0, 'hasVoted': False}}}, {'expand': 'operations,versionedRepresentations,editmeta,changelog,customfield_10010.requestTypePractice,renderedFields', 'id': '11438', 'self': 'https://my.url.net/rest/api/2/issue/11438', 'key': 'TS-1398', 'fields': {'statuscategorychangedate': '2022-11-29T07:05:09.126-0800', 'issuetype': {'self': 'https://my.url.net/rest/api/2/issuetype/10004', 'id': '10004', 'description': 'Functionality or a feature expressed as a user goal.', 'iconUrl': 'https://my.url.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10315?size=medium', 'name': 'Story', 'subtask': False, 'avatarId': 10315, 'hierarchyLevel': 0}, 'parent': {'id': '11420', 'key': 'TS-1380', 'self': 'https://my.url.net/rest/api/2/issue/11420', 'fields': {'summary': 'Clone30 - Migration Epics', 'status': {'self': 'https://my.url.net/rest/api/2/status/10003', 'description': '', 'iconUrl': 'https://my.url.net/', 'name': 'Backlog', 'id': '10003', 'statusCategory': {'self': 'https://my.url.net/rest/api/2/statuscategory/2', 'id': 2, 'key': 'new', 'colorName': 'blue-gray', 'name': 'To Do'}}, 'priority': {'self': 'https://my.url.net/rest/api/2/priority/3', 'iconUrl': 'https://my.url.net/images/icons/priorities/medium.svg', 'name': 'Medium', 'id': '3'}, 'issuetype': {'self': 'https://my.url.net/rest/api/2/issuetype/10000', 'id': '10000', 'description': 'A big user story that needs to be broken down. Created by Jira Software - do not edit or delete.', 'iconUrl': 'https://my.url.net/images/icons/issuetypes/epic.svg', 'name': 'Epic', 'subtask': False, 'hierarchyLevel': 1}}}, 'timespent': None, 'project': {'self': 'https://my.url.net/rest/api/2/project/10001', 'id': '10001', 'key': 'TS', 'name': 'Project', 'projectTypeKey': 'software', 'simplified': False, 'avatarUrls': {'48x48': 'https://my.url.net/rest/api/2/universal_avatar/view/type/project/avatar/10556', '24x24': 'https://my.url.net/rest/api/2/universal_avatar/view/type/project/avatar/10556?size=small', '16x16': 'https://my.url.net/rest/api/2/universal_avatar/view/type/project/avatar/10556?size=xsmall', '32x32': 'https://my.url.net/rest/api/2/universal_avatar/view/type/project/avatar/10556?size=medium'}}, 'fixVersions': [], 'customfield_10033': None, 'customfield_10034': [], 'aggregatetimespent': None, 'customfield_10035': None, 'resolution': None, 'customfield_10036': None, 'customfield_10037': None, 'customfield_10027': None, 'customfield_10028': None, 'customfield_10029': None, 'resolutiondate': None, 'workratio': -1, 'lastViewed': None, 'watches': {'self': 'https://my.url.net/rest/api/2/issue/TS-1398/watchers', 'watchCount': 1, 'isWatching': True}, 'created': '2022-11-29T07:05:08.312-0800', 'customfield_10020': None, 'customfield_10021': None, 'customfield_10022': None, 'customfield_10023': None, 'priority': {'self': 'https://my.url.net/rest/api/2/priority/3', 'iconUrl': 'https://my.url.net/images/icons/priorities/medium.svg', 'name': 'Medium', 'id': '3'}, 'customfield_10024': None, 'customfield_10025': None, 'customfield_10026': None, 'labels': [], 'customfield_10016': None, 'customfield_10017': None, 'customfield_10018': {'hasEpicLinkFieldDependency': False, 'showField': False, 'nonEditableReason': {'reason': 'EPIC_LINK_SHOULD_BE_USED', 'message': 'To set an epic as the parent, use the epic link instead'}}, 'customfield_10019': '0|i008ae:y', 'timeestimate': None, 'aggregatetimeoriginalestimate': None, 'versions': [], 'issuelinks': [], 'assignee': None, 'updated': '2022-11-29T07:05:22.417-0800', 'status': {'self': 'https://my.url.net/rest/api/2/status/10003', 'description': '', 'iconUrl': 'https://my.url.net/', 'name': 'Backlog', 'id': '10003', 'statusCategory': {'self': 'https://my.url.net/rest/api/2/statuscategory/2', 'id': 2, 'key': 'new', 'colorName': 'blue-gray', 'name': 'To Do'}}, 'components': [], 'timeoriginalestimate': None, 'description': 'Creating reports/reporting cubes; need to find out reports used', 'customfield_10010': None, 'customfield_10014': 'TS-1380', 'customfield_10015': None, 'customfield_10005': None, 'customfield_10006': None, 'security': None, 'customfield_10007': None, 'customfield_10008': None, 'customfield_10009': None, 'aggregatetimeestimate': None, 'summary': '\xa0create reports/cubes', 'creator': {'self': 'https://my.url.net/rest/api/2/user?accountId=5d669f4bf81f2c0d99ee9e38', 'accountId': '5d669f4bf81f2c0d99ee9e38', 'emailAddress': 'test@aol.com', 'avatarUrls': {'48x48': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '24x24': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '16x16': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '32x32': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png'}, 'displayName': 'Joe Test', 'active': True, 'timeZone': 'America/Los_Angeles', 'accountType': 'atlassian'}, 'subtasks': [{'id': '11439', 'key': 'TS-1399', 'self': 'https://my.url.net/rest/api/2/issue/11439', 'fields': {'summary': 'Confirm: any reporting cubes required using this data are created and in production?', 'status': {'self': 'https://my.url.net/rest/api/2/status/10003', 'description': '', 'iconUrl': 'https://my.url.net/', 'name': 'Backlog', 'id': '10003', 'statusCategory': {'self': 'https://my.url.net/rest/api/2/statuscategory/2', 'id': 2, 'key': 'new', 'colorName': 'blue-gray', 'name': 'To Do'}}, 'priority': {'self': 'https://my.url.net/rest/api/2/priority/3', 'iconUrl': 'https://my.url.net/images/icons/priorities/medium.svg', 'name': 'Medium', 'id': '3'}, 'issuetype': {'self': 'https://my.url.net/rest/api/2/issuetype/10006', 'id': '10006', 'description': "A small piece of work that's part of a larger task.", 'iconUrl': 'https://my.url.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10316?size=medium', 'name': 'Sub-task', 'subtask': True, 'avatarId': 10316, 'hierarchyLevel': -1}}}, {'id': '11440', 'key': 'TS-1400', 'self': 'https://my.url.net/rest/api/2/issue/11440', 'fields': {'summary': 'Confirm: any structured reports using this data are created and in production?', 'status': {'self': 'https://my.url.net/rest/api/2/status/10003', 'description': '', 'iconUrl': 'https://my.url.net/', 'name': 'Backlog', 'id': '10003', 'statusCategory': {'self': 'https://my.url.net/rest/api/2/statuscategory/2', 'id': 2, 'key': 'new', 'colorName': 'blue-gray', 'name': 'To Do'}}, 'priority': {'self': 'https://my.url.net/rest/api/2/priority/3', 'iconUrl': 'https://my.url.net/images/icons/priorities/medium.svg', 'name': 'Medium', 'id': '3'}, 'issuetype': {'self': 'https://my.url.net/rest/api/2/issuetype/10006', 'id': '10006', 'description': "A small piece of work that's part of a larger task.", 'iconUrl': 'https://my.url.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10316?size=medium', 'name': 'Sub-task', 'subtask': True, 'avatarId': 10316, 'hierarchyLevel': -1}}}], 'reporter': {'self': 'https://my.url.net/rest/api/2/user?accountId=5d669f4bf81f2c0d99ee9e38', 'accountId': '5d669f4bf81f2c0d99ee9e38', 'emailAddress': 'test@aol.com', 'avatarUrls': {'48x48': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '24x24': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '16x16': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '32x32': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png'}, 'displayName': 'Joe Test', 'active': True, 'timeZone': 'America/Los_Angeles', 'accountType': 'atlassian'}, 'aggregateprogress': {'progress': 0, 'total': 0}, 'customfield_10001': None, 'customfield_10002': None, 'customfield_10003': None, 'customfield_10004': None, 'customfield_10038': None, 'environment': None, 'duedate': None, 'progress': {'progress': 0, 'total': 0}, 'votes': {'self': 'https://my.url.net/rest/api/2/issue/TS-1398/votes', 'votes': 0, 'hasVoted': False}}}]

Body:
I'm using the code below to pull in multiple json files into 1 using pagination. When I try to create a spark dataframe I get the error '
java.lang.ArrayStoreException: java.util.HashMap' during spark.read.json. Below the code block I've provided output from printing the 'issues' data set (minus proprietary info). I've done a bit of research and can't figure out what I can try to make this work. Any assistance would be greatly appreciated!!

import requests
import json

limit = 2
startat = 0
issues = []

for page_num in range(2):
    startat = page_num*50
    url = f"https://URL/rest/api/2/search?jql=TEST&startAt={startat}&maxResults={limit}"
    req = requests.get(url, headers={'Accept': 'application/json', 'Authorization': 'Basic xxxxxxxxxxxxxxxxxxxxxxxxxx'})
    data = req.json()
    issues.extend(data['issues'])

jsonDF = spark.read.json(issues)
jsonDF.printSchema()

[{'expand': 'operations,versionedRepresentations,editmeta,changelog,customfield_10010.requestTypePractice,renderedFields', 'id': '11441', 'self': 'https://my.url.net/rest/api/2/issue/11441', 'key': 'TS-1401', 'fields': {'statuscategorychangedate': '2022-11-29T07:05:17.359-0800', 'issuetype': {'self': 'https://my.url.net/rest/api/2/issuetype/10004', 'id': '10004', 'description': 'Functionality or a feature expressed as a user goal.', 'iconUrl': 'https://my.url.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10315?size=medium', 'name': 'Story', 'subtask': False, 'avatarId': 10315, 'hierarchyLevel': 0}, 'parent': {'id': '11420', 'key': 'TS-1380', 'self': 'https://my.url.net/rest/api/2/issue/11420', 'fields': {'summary': 'Clone30 - Migration Epics', 'status': {'self': 'https://my.url.net/rest/api/2/status/10003', 'description': '', 'iconUrl': 'https://my.url.net/', 'name': 'Backlog', 'id': '10003', 'statusCategory': {'self': 'https://my.url.net/rest/api/2/statuscategory/2', 'id': 2, 'key': 'new', 'colorName': 'blue-gray', 'name': 'To Do'}}, 'priority': {'self': 'https://my.url.net/rest/api/2/priority/3', 'iconUrl': 'https://my.url.net/images/icons/priorities/medium.svg', 'name': 'Medium', 'id': '3'}, 'issuetype': {'self': 'https://my.url.net/rest/api/2/issuetype/10000', 'id': '10000', 'description': 'A big user story that needs to be broken down. Created by Jira Software - do not edit or delete.', 'iconUrl': 'https://my.url.net/images/icons/issuetypes/epic.svg', 'name': 'Epic', 'subtask': False, 'hierarchyLevel': 1}}}, 'timespent': None, 'project': {'self': 'https://my.url.net/rest/api/2/project/10001', 'id': '10001', 'key': 'TS', 'name': 'Project', 'projectTypeKey': 'software', 'simplified': False, 'avatarUrls': {'48x48': 'https://my.url.net/rest/api/2/universal_avatar/view/type/project/avatar/10556', '24x24': 'https://my.url.net/rest/api/2/universal_avatar/view/type/project/avatar/10556?size=small', '16x16': 'https://my.url.net/rest/api/2/universal_avatar/view/type/project/avatar/10556?size=xsmall', '32x32': 'https://my.url.net/rest/api/2/universal_avatar/view/type/project/avatar/10556?size=medium'}}, 'customfield_10033': None, 'fixVersions': [], 'aggregatetimespent': None, 'customfield_10034': [], 'customfield_10035': None, 'resolution': None, 'customfield_10036': None, 'customfield_10037': None, 'customfield_10027': None, 'customfield_10028': None, 'customfield_10029': None, 'resolutiondate': None, 'workratio': -1, 'watches': {'self': 'https://my.url.net/rest/api/2/issue/TS-1401/watchers', 'watchCount': 1, 'isWatching': True}, 'lastViewed': '2022-12-08T10:06:57.022-0800', 'created': '2022-11-29T07:05:16.501-0800', 'customfield_10020': None, 'customfield_10021': None, 'customfield_10022': None, 'priority': {'self': 'https://my.url.net/rest/api/2/priority/3', 'iconUrl': 'https://my.url.net/images/icons/priorities/medium.svg', 'name': 'Medium', 'id': '3'}, 'customfield_10023': None, 'customfield_10024': None, 'customfield_10025': None, 'customfield_10026': None, 'labels': [], 'customfield_10016': None, 'customfield_10017': None, 'customfield_10018': {'hasEpicLinkFieldDependency': False, 'showField': False, 'nonEditableReason': {'reason': 'EPIC_LINK_SHOULD_BE_USED', 'message': 'To set an epic as the parent, use the epic link instead'}}, 'customfield_10019': '0|i008a3:', 'timeestimate': None, 'aggregatetimeoriginalestimate': None, 'versions': [], 'issuelinks': [], 'assignee': None, 'updated': '2022-11-29T07:05:20.759-0800', 'status': {'self': 'https://my.url.net/rest/api/2/status/10003', 'description': '', 'iconUrl': 'https://my.url.net/', 'name': 'Backlog', 'id': '10003', 'statusCategory': {'self': 'https://my.url.net/rest/api/2/statuscategory/2', 'id': 2, 'key': 'new', 'colorName': 'blue-gray', 'name': 'To Do'}}, 'components': [], 'timeoriginalestimate': None, 'description': 'Data owner completes template (understand scope of migration efforts)', 'customfield_10010': None, 'customfield_10014': 'TS-1380', 'customfield_10015': None, 'customfield_10005': None, 'customfield_10006': None, 'customfield_10007': None, 'security': None, 'customfield_10008': None, 'customfield_10009': None, 'aggregatetimeestimate': None, 'summary': 'Template', 'creator': {'self': 'https://my.url.net/rest/api/2/user?accountId=5d669f4bf81f2c0d99ee9e38', 'accountId': '5d669f4bf81f2c0d99ee9e38', 'emailAddress': 'test@aol.com', 'avatarUrls': {'48x48': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '24x24': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '16x16': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '32x32': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png'}, 'displayName': 'Joe Test', 'active': True, 'timeZone': 'America/Los_Angeles', 'accountType': 'atlassian'}, 'subtasks': [{'id': '11442', 'key': 'TS-1402', 'self': 'https://my.url.net/rest/api/2/issue/11442', 'fields': {'summary': 'Complete Template with table/views required (in) and produced (out)', 'status': {'self': 'https://my.url.net/rest/api/2/status/10003', 'description': '', 'iconUrl': 'https://my.url.net/', 'name': 'Backlog', 'id': '10003', 'statusCategory': {'self': 'https://my.url.net/rest/api/2/statuscategory/2', 'id': 2, 'key': 'new', 'colorName': 'blue-gray', 'name': 'To Do'}}, 'priority': {'self': 'https://my.url.net/rest/api/2/priority/3', 'iconUrl': 'https://my.url.net/images/icons/priorities/medium.svg', 'name': 'Medium', 'id': '3'}, 'issuetype': {'self': 'https://my.url.net/rest/api/2/issuetype/10006', 'id': '10006', 'description': "A small piece of work that's part of a larger task.", 'iconUrl': 'https://my.url.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10316?size=medium', 'name': 'Sub-task', 'subtask': True, 'avatarId': 10316, 'hierarchyLevel': -1}}}], 'reporter': {'self': 'https://my.url.net/rest/api/2/user?accountId=5d669f4bf81f2c0d99ee9e38', 'accountId': '5d669f4bf81f2c0d99ee9e38', 'emailAddress': 'test@aol.com', 'avatarUrls': {'48x48': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '24x24': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '16x16': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '32x32': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png'}, 'displayName': 'Joe Test', 'active': True, 'timeZone': 'America/Los_Angeles', 'accountType': 'atlassian'}, 'aggregateprogress': {'progress': 0, 'total': 0}, 'customfield_10001': None, 'customfield_10002': None, 'customfield_10003': None, 'customfield_10004': None, 'customfield_10038': None, 'environment': None, 'duedate': None, 'progress': {'progress': 0, 'total': 0}, 'votes': {'self': 'https://my.url.net/rest/api/2/issue/TS-1401/votes', 'votes': 0, 'hasVoted': False}}}, {'expand': 'operations,versionedRepresentations,editmeta,changelog,customfield_10010.requestTypePractice,renderedFields', 'id': '11438', 'self': 'https://my.url.net/rest/api/2/issue/11438', 'key': 'TS-1398', 'fields': {'statuscategorychangedate': '2022-11-29T07:05:09.126-0800', 'issuetype': {'self': 'https://my.url.net/rest/api/2/issuetype/10004', 'id': '10004', 'description': 'Functionality or a feature expressed as a user goal.', 'iconUrl': 'https://my.url.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10315?size=medium', 'name': 'Story', 'subtask': False, 'avatarId': 10315, 'hierarchyLevel': 0}, 'parent': {'id': '11420', 'key': 'TS-1380', 'self': 'https://my.url.net/rest/api/2/issue/11420', 'fields': {'summary': 'Clone30 - Migration Epics', 'status': {'self': 'https://my.url.net/rest/api/2/status/10003', 'description': '', 'iconUrl': 'https://my.url.net/', 'name': 'Backlog', 'id': '10003', 'statusCategory': {'self': 'https://my.url.net/rest/api/2/statuscategory/2', 'id': 2, 'key': 'new', 'colorName': 'blue-gray', 'name': 'To Do'}}, 'priority': {'self': 'https://my.url.net/rest/api/2/priority/3', 'iconUrl': 'https://my.url.net/images/icons/priorities/medium.svg', 'name': 'Medium', 'id': '3'}, 'issuetype': {'self': 'https://my.url.net/rest/api/2/issuetype/10000', 'id': '10000', 'description': 'A big user story that needs to be broken down. Created by Jira Software - do not edit or delete.', 'iconUrl': 'https://my.url.net/images/icons/issuetypes/epic.svg', 'name': 'Epic', 'subtask': False, 'hierarchyLevel': 1}}}, 'timespent': None, 'project': {'self': 'https://my.url.net/rest/api/2/project/10001', 'id': '10001', 'key': 'TS', 'name': 'Project', 'projectTypeKey': 'software', 'simplified': False, 'avatarUrls': {'48x48': 'https://my.url.net/rest/api/2/universal_avatar/view/type/project/avatar/10556', '24x24': 'https://my.url.net/rest/api/2/universal_avatar/view/type/project/avatar/10556?size=small', '16x16': 'https://my.url.net/rest/api/2/universal_avatar/view/type/project/avatar/10556?size=xsmall', '32x32': 'https://my.url.net/rest/api/2/universal_avatar/view/type/project/avatar/10556?size=medium'}}, 'fixVersions': [], 'customfield_10033': None, 'customfield_10034': [], 'aggregatetimespent': None, 'customfield_10035': None, 'resolution': None, 'customfield_10036': None, 'customfield_10037': None, 'customfield_10027': None, 'customfield_10028': None, 'customfield_10029': None, 'resolutiondate': None, 'workratio': -1, 'lastViewed': None, 'watches': {'self': 'https://my.url.net/rest/api/2/issue/TS-1398/watchers', 'watchCount': 1, 'isWatching': True}, 'created': '2022-11-29T07:05:08.312-0800', 'customfield_10020': None, 'customfield_10021': None, 'customfield_10022': None, 'customfield_10023': None, 'priority': {'self': 'https://my.url.net/rest/api/2/priority/3', 'iconUrl': 'https://my.url.net/images/icons/priorities/medium.svg', 'name': 'Medium', 'id': '3'}, 'customfield_10024': None, 'customfield_10025': None, 'customfield_10026': None, 'labels': [], 'customfield_10016': None, 'customfield_10017': None, 'customfield_10018': {'hasEpicLinkFieldDependency': False, 'showField': False, 'nonEditableReason': {'reason': 'EPIC_LINK_SHOULD_BE_USED', 'message': 'To set an epic as the parent, use the epic link instead'}}, 'customfield_10019': '0|i008ae:y', 'timeestimate': None, 'aggregatetimeoriginalestimate': None, 'versions': [], 'issuelinks': [], 'assignee': None, 'updated': '2022-11-29T07:05:22.417-0800', 'status': {'self': 'https://my.url.net/rest/api/2/status/10003', 'description': '', 'iconUrl': 'https://my.url.net/', 'name': 'Backlog', 'id': '10003', 'statusCategory': {'self': 'https://my.url.net/rest/api/2/statuscategory/2', 'id': 2, 'key': 'new', 'colorName': 'blue-gray', 'name': 'To Do'}}, 'components': [], 'timeoriginalestimate': None, 'description': 'Creating reports/reporting cubes; need to find out reports used', 'customfield_10010': None, 'customfield_10014': 'TS-1380', 'customfield_10015': None, 'customfield_10005': None, 'customfield_10006': None, 'security': None, 'customfield_10007': None, 'customfield_10008': None, 'customfield_10009': None, 'aggregatetimeestimate': None, 'summary': '\xa0create reports/cubes', 'creator': {'self': 'https://my.url.net/rest/api/2/user?accountId=5d669f4bf81f2c0d99ee9e38', 'accountId': '5d669f4bf81f2c0d99ee9e38', 'emailAddress': 'test@aol.com', 'avatarUrls': {'48x48': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '24x24': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '16x16': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '32x32': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png'}, 'displayName': 'Joe Test', 'active': True, 'timeZone': 'America/Los_Angeles', 'accountType': 'atlassian'}, 'subtasks': [{'id': '11439', 'key': 'TS-1399', 'self': 'https://my.url.net/rest/api/2/issue/11439', 'fields': {'summary': 'Confirm: any reporting cubes required using this data are created and in production?', 'status': {'self': 'https://my.url.net/rest/api/2/status/10003', 'description': '', 'iconUrl': 'https://my.url.net/', 'name': 'Backlog', 'id': '10003', 'statusCategory': {'self': 'https://my.url.net/rest/api/2/statuscategory/2', 'id': 2, 'key': 'new', 'colorName': 'blue-gray', 'name': 'To Do'}}, 'priority': {'self': 'https://my.url.net/rest/api/2/priority/3', 'iconUrl': 'https://my.url.net/images/icons/priorities/medium.svg', 'name': 'Medium', 'id': '3'}, 'issuetype': {'self': 'https://my.url.net/rest/api/2/issuetype/10006', 'id': '10006', 'description': "A small piece of work that's part of a larger task.", 'iconUrl': 'https://my.url.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10316?size=medium', 'name': 'Sub-task', 'subtask': True, 'avatarId': 10316, 'hierarchyLevel': -1}}}, {'id': '11440', 'key': 'TS-1400', 'self': 'https://my.url.net/rest/api/2/issue/11440', 'fields': {'summary': 'Confirm: any structured reports using this data are created and in production?', 'status': {'self': 'https://my.url.net/rest/api/2/status/10003', 'description': '', 'iconUrl': 'https://my.url.net/', 'name': 'Backlog', 'id': '10003', 'statusCategory': {'self': 'https://my.url.net/rest/api/2/statuscategory/2', 'id': 2, 'key': 'new', 'colorName': 'blue-gray', 'name': 'To Do'}}, 'priority': {'self': 'https://my.url.net/rest/api/2/priority/3', 'iconUrl': 'https://my.url.net/images/icons/priorities/medium.svg', 'name': 'Medium', 'id': '3'}, 'issuetype': {'self': 'https://my.url.net/rest/api/2/issuetype/10006', 'id': '10006', 'description': "A small piece of work that's part of a larger task.", 'iconUrl': 'https://my.url.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10316?size=medium', 'name': 'Sub-task', 'subtask': True, 'avatarId': 10316, 'hierarchyLevel': -1}}}], 'reporter': {'self': 'https://my.url.net/rest/api/2/user?accountId=5d669f4bf81f2c0d99ee9e38', 'accountId': '5d669f4bf81f2c0d99ee9e38', 'emailAddress': 'test@aol.com', 'avatarUrls': {'48x48': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '24x24': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '16x16': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png', '32x32': 'https://secure.gravatar.com/avatar/69b7db33e65c274c27a07b28b356e329?d=https%3A%2F%2Favatar-management--avatars.us-west-2.test.png'}, 'displayName': 'Joe Test', 'active': True, 'timeZone': 'America/Los_Angeles', 'accountType': 'atlassian'}, 'aggregateprogress': {'progress': 0, 'total': 0}, 'customfield_10001': None, 'customfield_10002': None, 'customfield_10003': None, 'customfield_10004': None, 'customfield_10038': None, 'environment': None, 'duedate': None, 'progress': {'progress': 0, 'total': 0}, 'votes': {'self': 'https://my.url.net/rest/api/2/issue/TS-1398/votes', 'votes': 0, 'hasVoted': False}}}]


来源: stackexchange

问:
Why taken photo is not visible with SwiftUI?
I would make possible to take two photos, with one UIViewControllerRepresentable and Coordinator, but photo will not appear, why?

struct ContentView: View {
    @State var camera = false
    @State private var holeTop: UIImage?
    @State private var holeBottom: UIImage?
    @State private var selectedImage: UIImage?

    var body: some View {
        VStack(spacing: 0) {
            Form {
                Section {
                    HStack {
                        Circle()
                            .foregroundColor(.red)
                            .shadow(radius: 4)
                            .frame(width: 44, height: 44)
                            .overlay {
                                holeTop != nil ? Image(uiImage: holeTop!).resizable()
                                    .scaledToFit()
                                    .frame(width: 24, height: 24)
                                    .foregroundColor(.white) :
                                Image(systemName: "camera")
                                    .resizable()
                                    .scaledToFit()
                                    .frame(width: 24, height: 24)
                                    .foregroundColor(.white)
                            }.onTapGesture {
                                selectedImage = holeTop
                                camera = true
                            }.padding(24)
                        Text("Hole top")
                            .foregroundColor(.gray)
                    }
                    HStack {
                        Circle()
                            .foregroundColor(.red)
                            .shadow(radius: 4)
                            .frame(width: 44, height: 44)
                            .overlay {
                                holeTop != nil ? Image(uiImage: holeBottom!).resizable()
                                    .scaledToFit()
                                    .frame(width: 24, height: 24)
                                    .foregroundColor(.white) :
                                Image(systemName: "camera")
                                    .resizable()
                                    .scaledToFit()
                                    .frame(width: 24, height: 24)
                                    .foregroundColor(.white)
                            }.onTapGesture {
                                selectedImage = holeBottom
                                camera = true
                            }.padding(24)
                        Text("Hole bottom")
                            .foregroundColor(.gray)
                    }
                } header: {
                    Text("")
                }
            }
        }.sheet(isPresented: $camera) {
            CameraView(selectedImage: $selectedImage)
        }
    }
}

struct CameraView: UIViewControllerRepresentable {
    @Binding var selectedImage: UIImage?
    @Environment(\.presentationMode) var isPresented

    func makeUIViewController(context: Context) -> UIImagePickerController {
        let picker = UIImagePickerController()
        picker.delegate = context.coordinator
        return picker
    }

    func updateUIViewController(_ uiViewController: UIImagePickerController, context: Context) {
        uiViewController.sourceType = .camera
    }

    func makeCoordinator() -> Coordinator {
        Coordinator(picker: self)
    }
}

class Coordinator: NSObject, UINavigationControllerDelegate, UIImagePickerControllerDelegate {
    var picker: CameraView

    init(picker: CameraView) {
        self.picker = picker
    }

    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
        guard let selectedImage = info[.originalImage] as? UIImage else { return }
        self.picker.selectedImage = selectedImage
        self.picker.isPresented.wrappedValue.dismiss()
    }
}
```

ContentLicense: CC BY-SA 4.0


问:
How can I make a directory in Android?
When I use the method mkdirs() in Android Studio I get this runtime error

Got a deoptimization request on un-DE optimizable method Boolean libcore.io.Linux.access(java.lang.String, int)

Can anyone solve it?

I wanted to make one directory in the storage, then make a file in it, but neither mkdirs() works nor createnewfile

Title: How can I make a directory in Android?


问:
Compare and replace key in JSON using python
I have a file file1.json

```<code>[
   {
      "user_id": "123",
      "provider": true,
      "username": "admin1",
      "id": "rol_123"
   },
   {
      "user_id": "234",
      "provider": true,
      "username": "admin2",
      "id": "rol_234"
   },
]
</code>```

and a file file2.json:

```<code>[
   {
      "user_id": "12345",
      "provider": true,
      "username": "admin1",
   },
   {
      "user_id": "23456",
      "provider": true,
      "username": "admin2",
   },
]
</code>```

I want to compare user_id and username and mark the changes in provider in a different file,  file3.json . I have a feeling we can use some kind of loop to resolve this, can someone help me out please. Thanks.

Body:
I have a file file1.json

[
   {
      "user_id": "123",
      "provider": true,
      "username": "admin1",
      "id": "rol_123"
   },
   {
      "user_id": "234",
      "provider": true,
      "username": "admin2",
      "id": "rol_234"
   },
]

and a file file2.json:

[
   {
      "user_id": "12345",
      "provider": true,
      "username": "admin1",
   },
   {
      "user_id": "23456",
      "provider": true,
      "username": "admin2",
   },
]

I want to compare user_id and username and mark the changes in provider in a different file,  file3.json . I have a feeling we can use some kind of loop to resolve this, can someone help me out please. Thanks.


问:
Angular Universal save data to session
I'm building an SSR site using Angular Universal. I need to get a VERY big array of data to be available to send as a body to various apis later in the site. I know I could use session cookies but there is a 4kb limit on that and my array is much bigger than 4kb. Has anyone encountered this before?

btw since this is ssr and not spa, storing a variable into a service isn't an option as it will get wiped upon the user clicking each href. I've also tried using transferState but this only seems to be used to prevent duplicate requests and that cache isn't remembered per page refresh.

Title: Angular Universal save data to session


问:
How do you access (Py)Spark-context variables locally in the notebook (SageMaker Studio)?
I built a model in PySpark that is available on all worker nodes, but I would like to generate some model-related plots in the notebook. The model itself is available in a Spark-context, but it is not available in the notebook-context so that I can make plots. How do I make the model available in the notebook-context?

For more context, here is a shell of my PySpark code:

```<code>df = spark.read.parquet('path_to_my_data')
import h2o
h2o.init()
df_h2o = h2o.H2OFrame(df)
model = H2OGradientBoostingEstimator(ntrees=100)
model.train(x = ['var1', 'var2', 'var3'],
            y = 'yvar',
            training_frame = df_h2o)
# --- NOW I WANT TO MAKE PLOTS FOR THE MODEL ---
# This does not return a plot to the notebook
model.varimp_plot()
</code>```

Of course, the code model.varimp_plot() does not return a plot because the plot is being returned on the worker nodes as opposed to the notebook. I have seen a lot of people do something like this:

```<code>%%local
import matplotlib.pyplot as plt
a = [1,2,3,4,5]
plt.plot(a)
</code>```

and I tried something like this for my problem:

```<code>%%local
import matplotlib.pyplot as plt
model.varimp_plot()
</code>```

but it does not work since model is only defined in a Spark-context (not the notebook context). The error I receive is NameError: name 'model' is not defined.

My question: How do I access model in the notebook context? Put another way, how do I access model in the %%local block of code?

Body:
I built a model in PySpark that is available on all worker nodes, but I would like to generate some model-related plots in the notebook. The model itself is available in a Spark-context, but it is not available in the notebook-context so that I can make plots. How do I make the model available in the notebook-context?

For more context, here is a shell of my PySpark code:

df = spark.read.parquet('path_to_my_data')
import h2o
h2o.init()
df_h2o = h2o.H2OFrame(df)
model = H2OGradientBoostingEstimator(ntrees=100)
model.train(x = ['var1', 'var2', 'var3'],
            y = 'yvar',
            training_frame = df_h2o)
# --- NOW I WANT TO MAKE PLOTS FOR THE MODEL ---
# This does not return a plot to the notebook
model.varimp_plot()

Of course, the code model.varimp_plot() does not return a plot because the plot is being returned on the worker nodes as opposed to the notebook. I have seen a lot of people do something like this:

%%local
import matplotlib.pyplot as plt
a = [1,2,3,4,5]
plt.plot(a)

and I tried something like this for my problem:

%%local
import matplotlib.pyplot as plt
model.varimp_plot()

but it does not work since model is only defined in a Spark-context (not the notebook context). The error I receive is NameError: name 'model' is not defined.

My question: How do I access model in the notebook context? Put another way, how do I access model in the %%local block of code?


问:
#Rails ActiveRecord::RecordNotFound in ActiveStorage::BlobsController#show
Getting error of

```<code>Couldn't find ActiveStorage::Blob with 'id'=41
</code>```

I am trying to read blog attachments and see the images and download them. It works sometimes and doesn't works when server is restarted.

My show.html.haml view template is

```<code>%h1.page-heading
  %a{href: admin_tenant_site_unit_floor_plans_path}
    %i.material-icons.left arrow_back
  Listing Images

  %small= "of Floor Plan #{@floor_plan.id}"

.row
  .col.s8
    %table.report
      %thead
        %tr
          %th= "Blob_id"
          %th= "Name"
          %th= "Record type"
          %th
            %i.material-icons visibility
          %th
            %i.material-icons download

      %tbody
        - if @floor_plan.floor_image.attached?
          - @floor_plan.floor_image.each do |image|
            %tr
              %td= image.blob_id
              %td= image.name
              %td= image.record_type
              -# %td= link_to "Download " + image.record_type + " " + image.blob_id.to_s, rails_blob_path(image, disposition: "attachment"), target: '_blank'
              %td= link_to "View " + image.record_type + " " + image.blob_id.to_s, url_for(image), target: '_blank'
              %td= link_to "Download " + image.record_type + " " + image.blob_id.to_s, rails_blob_path(image, disposition: "attachment"), target: '_blank'

</code>```

Controller action :

```<code>      def show
        # binding.b
        @floor_plan = FloorPlan.find(params[:id])
      end
</code>```

Also index.html.haml :

```<code>= render(partial: 'admin/units/sublinks')
%h5.section-heading.mt20
  Listing Floor plans
.row
  .col.s8
    %table.report
      %thead
        %tr
          %th= "Name"
          %th= sortable "created_at", "Submission Date"
      %tbody
        - @floor_plans.each do |plan|
          %tr
            %td= plan.name
            %td= plan.created_at.strftime("%b %d, %Y %r")
            %td
              %a.dropdown-trigger.btn.waves-effect.waves-teal.btn-flat.right{"data-target" => "client_dropdown#{plan.id}", :href => "#"}
                %i.material-icons.right>expand_more
                More
              %ul.dropdown-content{id: "client_dropdown#{plan.id}"}
                %li
                  = link_to "Show", admin_tenant_site_unit_floor_plan_path(@tenant, @site, @unit, plan)
                - if plan.floor_image.attached?
                  - plan.floor_image.each do |image|
                    - p "+++++++++++++++++++++++++++"
                    - p plan
                    - p image
                    - p image.blob_id
                    %li
                      = link_to "View " + image.record_type + " " + image.blob_id.to_s, url_for(image), target: '_blank'
                    %li
                      = link_to "Download " + image.record_type + " " + image.blob_id.to_s, rails_blob_path(image, disposition: "attachment"), target: '_blank'
                %li
                  = link_to 'Edit name',
                  edit_admin_tenant_site_unit_floor_plan_path(@tenant, @site, @unit, plan)
                %li
                  = link_to 'Delete', [:admin, @tenant, @site, @unit, plan], method: :delete, data: { confirm: 'Are you sure?' }
</code>```

FloorPlan.rd model file :

```<code>class FloorPlan < ApplicationRecord
  belongs_to :unit
  has_many_attached :floor_image, dependent: :destroy
  validates :name, presence:true
  validates :floor_image, presence:true
end
</code>```

And here is the snippet from schema.rb

```<code>  create_table "floor_plans", force: :cascade do |t|
    t.string "name", null: false
    t.bigint "unit_id", null: false
    t.datetime "created_at", precision: 6, null: false
    t.datetime "updated_at", precision: 6, null: false
    t.index ["unit_id"], name: "index_floor_plans_on_unit_id"
  end
</code>```

The error doesn't come up when the exactly same system I used in other component of the app. But the error is persistent upon clicking the "View" and "Download" links in show and index templates.

Please guide me to resolve this error and to understand the root cause.

Also I wanna print the name of the blob items instead of printing names from the active_storage_attachments table.

Body:
Getting error of

Couldn't find ActiveStorage::Blob with 'id'=41

I am trying to read blog attachments and see the images and download them. It works sometimes and doesn't works when server is restarted.

My show.html.haml view template is

%h1.page-heading
  %a{href: admin_tenant_site_unit_floor_plans_path}
    %i.material-icons.left arrow_back
  Listing Images

  %small= "of Floor Plan #{@floor_plan.id}"

.row
  .col.s8
    %table.report
      %thead
        %tr
          %th= "Blob_id"
          %th= "Name"
          %th= "Record type"
          %th
            %i.material-icons visibility
          %th
            %i.material-icons download

      %tbody
        - if @floor_plan.floor_image.attached?
          - @floor_plan.floor_image.each do |image|
            %tr
              %td= image.blob_id
              %td= image.name
              %td= image.record_type
              -# %td= link_to "Download " + image.record_type + " " + image.blob_id.to_s, rails_blob_path(image, disposition: "attachment"), target: '_blank'
              %td= link_to "View " + image.record_type + " " + image.blob_id.to_s, url_for(image), target: '_blank'
              %td= link_to "Download " + image.record_type + " " + image.blob_id.to_s, rails_blob_path(image, disposition: "attachment"), target: '_blank'

Controller action :

      def show
        # binding.b
        @floor_plan = FloorPlan.find(params[:id])
      end

Also index.html.haml :

= render(partial: 'admin/units/sublinks')
%h5.section-heading.mt20
  Listing Floor plans
.row
  .col.s8
    %table.report
      %thead
        %tr
          %th= "Name"
          %th= sortable "created_at", "Submission Date"
      %tbody
        - @floor_plans.each do |plan|
          %tr
            %td= plan.name
            %td= plan.created_at.strftime("%b %d, %Y %r")
            %td
              %a.dropdown-trigger.btn.waves-effect.waves-teal.btn-flat.right{"data-target" => "client_dropdown#{plan.id}", :href => "#"}
                %i.material-icons.right>expand_more
                More
              %ul.dropdown-content{id: "client_dropdown#{plan.id}"}
                %li
                  = link_to "Show", admin_tenant_site_unit_floor_plan_path(@tenant, @site, @unit, plan)
                - if plan.floor_image.attached?
                  - plan.floor_image.each do |image|
                    - p "+++++++++++++++++++++++++++"
                    - p plan
                    - p image
                    - p image.blob_id
                    %li
                      = link_to "View " + image.record_type + " " + image.blob_id.to_s, url_for(image), target: '_blank'
                    %li
                      = link_to "Download " + image.record_type + " " + image.blob_id.to_s, rails_blob_path(image, disposition: "attachment"), target: '_blank'
                %li
                  = link_to 'Edit name',
                  edit_admin_tenant_site_unit_floor_plan_path(@tenant, @site, @unit, plan)
                %li
                  = link_to 'Delete', [:admin, @tenant, @site, @unit, plan], method: :delete, data: { confirm: 'Are you sure?' }

FloorPlan.rd model file :

class FloorPlan < ApplicationRecord
  belongs_to :unit
  has_many_attached :floor_image, dependent: :destroy
  validates :name, presence:true
  validates :floor_image, presence:true
end

And here is the snippet from schema.rb

  create_table "floor_plans", force: :cascade do |t|
    t.string "name", null: false
    t.bigint "unit_id", null: false
    t.datetime "created_at", precision: 6, null: false
    t.datetime "updated_at", precision: 6, null: false
    t.index ["unit_id"], name: "index_floor_plans_on_unit_id"
  end

The error doesn't come up when the exactly same system I used in other component of the app. But the error is persistent upon clicking the "View" and "Download" links in show and index templates.

Please guide me to resolve this error and to understand the root cause.

Also I wanna print the name of the blob items instead of printing names from the active_storage_attachments table.


问:
Why can't I install a library with a minus sign in it?
I'm new to Python and I'm trying to import a module that I installed, "python-evtx".  I successfully installed it, but when I try to import it in the environment (Python 3.10.9) using Idle I get a syntax error that points at the "-" sign. As far as I can tell, import chokes on that"-" sign.  Can anybody help?  Thanks!

Here is a screenshot of my issue:

(https://i.stack.imgur.com/h9oxj.png)


问:
How can I run useEffect on state change only and not on mount?
So I have some logic I want to run on state change, but not on mount. The default state value is an empty object.(currentTarget is the state). So I figured an if statement would do the trick.

```<code>const fetchChat = async () => {
    const getChatData = await fetch('http://localhost:3001/getChat')
    const chatData = await getChatData.json()
    const checkForChat = chatData.some((chat) => {
      return chat.psuedoID.includes(userInfo._id) && chat.psuedoID.includes(currentTarget._id)
    })
    console.log(checkForChat)
    if (checkForChat === false) {
      createChat([userInfo._id, currentTarget._id])
    }
  }

  useEffect(() => {
    if (currentTarget !== {}) {
      console.log(currentTarget)
      fetchChat()
    }
  }, [currentTarget])
</code>```

Despite the console log showing that the state hasn't changed and is still an empty object, the logic within the if statement is still running on mount.

Body:
So I have some logic I want to run on state change, but not on mount. The default state value is an empty object.(currentTarget is the state). So I figured an if statement would do the trick.

const fetchChat = async () => {
    const getChatData = await fetch('http://localhost:3001/getChat')
    const chatData = await getChatData.json()
    const checkForChat = chatData.some((chat) => {
      return chat.psuedoID.includes(userInfo._id) && chat.psuedoID.includes(currentTarget._id)
    })
    console.log(checkForChat)
    if (checkForChat === false) {
      createChat([userInfo._id, currentTarget._id])
    }
  }

  useEffect(() => {
    if (currentTarget !== {}) {
      console.log(currentTarget)
      fetchChat()
    }
  }, [currentTarget])

Despite the console log showing that the state hasn't changed and is still an empty object, the logic within the if statement is still running on mount.


问:
Linker cannot find libpq library while cross-compiling rust application
I'm trying to cross-compile rust application using cross. Hello application compiles with no issue. The problem is when I try to use a diesel package with postgres support which depends on libpq library.

I did the installation of the libpq-dev package on my machine and I included a sys-pq package to my Cargo.toml, but it did not help.

How can I solve this?

Error:

```<code>➜ cross build --target armv7-unknown-linux-musleabi
   Compiling libc v0.2.138
   Compiling cfg-if v1.0.0
   Compiling version_check v0.9.4
   Compiling autocfg v1.1.0
   Compiling memchr v2.5.0
...
  = note: /usr/local/bin/../lib/gcc/arm-linux-musleabi/9.2.0/../../../../arm-linux-musleabi/bin/ld: cannot find -lpq
          collect2: error: ld returned 1 exit status
</code>```
```<code>➜ cat Cargo.toml
[package]
name = "webserver"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
actix-web = "4"
env_logger = "0.9"
futures-util = { version = "0.3.17", default-features = false, features = ["std"] }
json = "0.12"
log = "0.4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
diesel = { version = "2.0.0", features = ["postgres"] }
dotenvy = "0.15"
# Cross dependencies
pq-sys = "0.4.7"

[profile.release]
strip = true
opt-level = "z"
lto = true
</code>```

Body:
I'm trying to cross-compile rust application using cross. Hello application compiles with no issue. The problem is when I try to use a diesel package with postgres support which depends on libpq library.

I did the installation of the libpq-dev package on my machine and I included a sys-pq package to my Cargo.toml, but it did not help.

How can I solve this?

Error:

➜ cross build --target armv7-unknown-linux-musleabi
   Compiling libc v0.2.138
   Compiling cfg-if v1.0.0
   Compiling version_check v0.9.4
   Compiling autocfg v1.1.0
   Compiling memchr v2.5.0
...
  = note: /usr/local/bin/../lib/gcc/arm-linux-musleabi/9.2.0/../../../../arm-linux-musleabi/bin/ld: cannot find -lpq
          collect2: error: ld returned 1 exit status

➜ cat Cargo.toml
[package]
name = "webserver"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
actix-web = "4"
env_logger = "0.9"
futures-util = { version = "0.3.17", default-features = false, features = ["std"] }
json = "0.12"
log = "0.4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
diesel = { version = "2.0.0", features = ["postgres"] }
dotenvy = "0.15"
# Cross dependencies
pq-sys = "0.4.7"

[profile.release]
strip = true
opt-level = "z"
lto = true


问:
OSMnx: AttributeError: 'DataFrame' object has no attribute 'crs'
This snipped form the documentation leads to the following error

```<code>G = ox.graph_from_bbox(37.79, 37.78, -122.41, -122.43, network_type='drive')
G_projected = ox.project_graph(G)
ox.plot_graph(G_projected)
</code>```
```<code>C:\ProgramData\Miniconda3\envs\ox\lib\site-packages\osmnx\utils_geo.py:280: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
  for polygon in geometry:
C:\ProgramData\Miniconda3\envs\ox\lib\site-packages\osmnx\utils_geo.py:374: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
  for poly in multipoly:
C:\ProgramData\Miniconda3\envs\ox\lib\site-packages\osmnx\utils_geo.py:374: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
  for poly in multipoly:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[32], line 2
      1 G = ox.graph_from_bbox(37.79, 37.78, -122.41, -122.43, network_type='drive')
----> 2 G_projected = ox.project_graph(G)
      3 ox.plot_graph(G_projected)

File C:\ProgramData\Miniconda3\envs\ox\lib\site-packages\osmnx\projection.py:144, in project_graph(G, to_crs)
    141 if "simplified" in G.graph and G.graph["simplified"]:
    142     # if graph has previously been simplified, project the edge geometries
    143     gdf_edges = utils_graph.graph_to_gdfs(G, nodes=False, fill_edge_geometry=True)
--> 144     gdf_edges_proj = project_gdf(gdf_edges, to_crs=gdf_nodes_proj.crs)
    145 else:
    146     # if not, you don't have to project these edges because the nodes
    147     # contain all the spatial data in the graph (unsimplified edges have
    148     # no geometry attributes)
    149     gdf_edges_proj = utils_graph.graph_to_gdfs(G, nodes=False, fill_edge_geometry=False).drop(
    150         columns=["geometry"]
    151     )

File C:\ProgramData\Miniconda3\envs\ox\lib\site-packages\pandas\core\generic.py:5902, in NDFrame.__getattr__(self, name)
   5895 if (
   5896     name not in self._internal_names_set
   5897     and name not in self._metadata
   5898     and name not in self._accessors
   5899     and self._info_axis._can_hold_identifiers_and_holds_name(name)
   5900 ):
   5901     return self[name]
-> 5902 return object.__getattribute__(self, name)

AttributeError: 'DataFrame' object has no attribute 'crs'
</code>```

Can anybody help?

I already tried python 3.7 and 3.9. I do not have a clue why this error happens because i used an example from the demo repository. Maybe i did something wrong with the versions?

Update

Duplicate of 'DataFrame' object has no attribute 'crs'

Body:
This snipped form the documentation leads to the following error

G = ox.graph_from_bbox(37.79, 37.78, -122.41, -122.43, network_type='drive')
G_projected = ox.project_graph(G)
ox.plot_graph(G_projected)

C:\ProgramData\Miniconda3\envs\ox\lib\site-packages\osmnx\utils_geo.py:280: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
  for polygon in geometry:
C:\ProgramData\Miniconda3\envs\ox\lib\site-packages\osmnx\utils_geo.py:374: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
  for poly in multipoly:
C:\ProgramData\Miniconda3\envs\ox\lib\site-packages\osmnx\utils_geo.py:374: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
  for poly in multipoly:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[32], line 2
      1 G = ox.graph_from_bbox(37.79, 37.78, -122.41, -122.43, network_type='drive')
----> 2 G_projected = ox.project_graph(G)
      3 ox.plot_graph(G_projected)

File C:\ProgramData\Miniconda3\envs\ox\lib\site-packages\osmnx\projection.py:144, in project_graph(G, to_crs)
    141 if "simplified" in G.graph and G.graph["simplified"]:
    142     # if graph has previously been simplified, project the edge geometries
    143     gdf_edges = utils_graph.graph_to_gdfs(G, nodes=False, fill_edge_geometry=True)
--> 144     gdf_edges_proj = project_gdf(gdf_edges, to_crs=gdf_nodes_proj.crs)
    145 else:
    146     # if not, you don't have to project these edges because the nodes
    147     # contain all the spatial data in the graph (unsimplified edges have
    148     # no geometry attributes)
    149     gdf_edges_proj = utils_graph.graph_to_gdfs(G, nodes=False, fill_edge_geometry=False).drop(
    150         columns=["geometry"]
    151     )

File C:\ProgramData\Miniconda3\envs\ox\lib\site-packages\pandas\core\generic.py:5902, in NDFrame.__getattr__(self, name)
   5895 if (
   5896     name not in self._internal_names_set
   5897     and name not in self._metadata
   5898     and name not in self._accessors
   5899     and self._info_axis._can_hold_identifiers_and_holds_name(name)
   5900 ):
   5901     return self[name]
-> 5902 return object.__getattribute__(self, name)

AttributeError: 'DataFrame' object has no attribute 'crs'

Can anybody help?

I already tried python 3.7 and 3.9. I do not have a clue why this error happens because i used an example from the demo repository. Maybe i did something wrong with the versions?

Update

Duplicate of 'DataFrame' object has no attribute 'crs'


问:
Multi input/output with autoencoder type network with feedback layers
Hi I have the following multi input x = [k], [a], [u1, u2, u3,..., uN]. and outputs y = [b], [w1, w2, w3, ..., wN]. where:

k, N are integers. k<N

a, b are vectors of same dimensions.

u1, u2, ..., uN, w1, w2, w3,..., wN are of same dimensions.

Suppose NN represent my neural network, constructed as follows:

```<code>out_1 = encoder(a)
out_2 = encoder(ui)
out_3 = some_Dense_network(out_1, out_2)
b = decoder(out_3)
w = decoder(out_3)
</code>```

It essentially has two inputs and two outputs

```<code>NN= Model(inputs=[a, u], outputs = [b, w])
</code>```

I am trying to compute my outputs as follows in a feedback loop

```<code>u =[u1, u2, u3,..., uN]
w = [w1, w2, w3, ..., wN]
for i in range(k):
    a, w[i] = NN(a, u[k]) # this is the feedback loop
b = a # is the final output
</code>```

I wrote the code with multiple inputs and outputs (NN) in Tensorflow.

After this I tried the following:

```<code>final_model = Model(inputs=[k, a, u1, u2,.., uN], outputs = [b, w1, w2,...,wN])
</code>```

This did not work.

Body:
Hi I have the following multi input x = [k], [a], [u1, u2, u3,..., uN]. and outputs y = [b], [w1, w2, w3, ..., wN]. where:

k, N are integers. k<N

a, b are vectors of same dimensions.

u1, u2, ..., uN, w1, w2, w3,..., wN are of same dimensions.

Suppose NN represent my neural network, constructed as follows:

out_1 = encoder(a)
out_2 = encoder(ui)
out_3 = some_Dense_network(out_1, out_2)
b = decoder(out_3)
w = decoder(out_3)

It essentially has two inputs and two outputs

NN= Model(inputs=[a, u], outputs = [b, w])

I am trying to compute my outputs as follows in a feedback loop

u =[u1, u2, u3,..., uN]
w = [w1, w2, w3, ..., wN]
for i in range(k):
    a, w[i] = NN(a, u[k]) # this is the feedback loop
b = a # is the final output

I wrote the code with multiple inputs and outputs (NN) in Tensorflow.

After this I tried the following:

final_model = Model(inputs=[k, a, u1, u2,.., uN], outputs = [b, w1, w2,...,wN])

This did not work.


问:
CORB is blocking image rendering of an image when requested from another domain I own
CORB is blocking image rendering of an image when requested from another domain I own.

The image request is through a REST api that is proxying the image since it's actual source is in AWS S3.

Url making the request: https://app-ppd1.w...s.com/flow/primary-home/home-photo

Request url: https://app-preprod1.w...s.com/api/v1/asset/image/pid70XYfKBezg0s3bK1CDvA0dE8xIw07hUNvVjR4km0Je1Hi/150x150

I am able to successful make other cross domain network requests across these domains.  The app serves it's front end from https://app-ppd1.w...s.com and back-end from https://app-preprod1.w...s.com

The chrome error

Cross-Origin Read Blocking (CORB) blocked cross-origin response https://app-preprod1.w...s.com/ with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.

The image api has the following headers set:

access-control-allow-credentials: true

access-control-allow-origin: https://app-ppd1.w...s.com

cache-control: no-cache, private

content-disposition: attachment; filename=pid70XYfKBezg0s3bK1CDvA0dE8xIw07hUNvVjR4km0Je1Hi

content-length: 12269

content-type: image/jpeg

...

The network request succeeds with 200 and the images is returned, but Chrome doesn't render it.

Network response details:

The image is successfully returned:

The image src attribute is set via react state variable.

```<code>const setHomeImage = async (
  fileName: string,
): Promise<void> => {
  const homeImagePath = `${laravelApiV1}${
    AssetImage.path
  }/${fileName}/${HOME_IMAGE_DIMENSIONS}`;
  try {
    // try to get this image over the network
    await network.callGet(homeImagePath, true);
    setProcessingImage(false);
    setAssetImagePath(homeImagePath);
  } catch (error) {
    setProcessingImage(false);
    setAssetImagePath(undefined);
  }
};
</code>```
```<code>const getHomeElement = (): JSX.Element => {
  if (processingImage) {
    return <Loading />;
  } else if (assetImagePath) {
    return (
      <img
        src={assetImagePath}
        alt="Primary Home"
        title="Primary Home"
        width="150"
        height="150"
      />
    );
  } else {
    return (
      <img
        srcSet={`${simplePurpleHouse15} 1.5x, ${simplePurpleHouse2} 2x, ${simplePurpleHouse3} 3x`}
        src={simplePurpleHouse1}
        alt="Primary Home"
        title="Primary Home"
        width="150"
        height="150"
      />
    );
  }
};
</code>```

From what I've read it seems like the content-type: image/jpeg header should solve the problem, but Chrome still seems to see the mime-type as text/html despite the header I've set.

reference:
https://chromium.googlesource.com/chromium/src/+/master/services/network/cross_origin_read_blocking_explainer.md#Observable-CORB-impact-on-images

I also tried adding crossorigin="anonymous", but that did not solve the problem

Body:
CORB is blocking image rendering of an image when requested from another domain I own.

The image request is through a REST api that is proxying the image since it's actual source is in AWS S3.

Url making the request: https://app-ppd1.w...s.com/flow/primary-home/home-photo

Request url: https://app-preprod1.w...s.com/api/v1/asset/image/pid70XYfKBezg0s3bK1CDvA0dE8xIw07hUNvVjR4km0Je1Hi/150x150

I am able to successful make other cross domain network requests across these domains.  The app serves it's front end from https://app-ppd1.w...s.com and back-end from https://app-preprod1.w...s.com

The chrome error

Cross-Origin Read Blocking (CORB) blocked cross-origin response https://app-preprod1.w...s.com/ with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.

The image api has the following headers set:

access-control-allow-credentials: true

access-control-allow-origin: https://app-ppd1.w...s.com

cache-control: no-cache, private

content-disposition: attachment; filename=pid70XYfKBezg0s3bK1CDvA0dE8xIw07hUNvVjR4km0Je1Hi

content-length: 12269

content-type: image/jpeg

...

The network request succeeds with 200 and the images is returned, but Chrome doesn't render it.

Network response details:

The image is successfully returned:

The image src attribute is set via react state variable.

const setHomeImage = async (
  fileName: string,
): Promise<void> => {
  const homeImagePath = `${laravelApiV1}${
    AssetImage.path
  }/${fileName}/${HOME_IMAGE_DIMENSIONS}`;
  try {
    // try to get this image over the network
    await network.callGet(homeImagePath, true);
    setProcessingImage(false);
    setAssetImagePath(homeImagePath);
  } catch (error) {
    setProcessingImage(false);
    setAssetImagePath(undefined);
  }
};

const getHomeElement = (): JSX.Element => {
  if (processingImage) {
    return <Loading />;
  } else if (assetImagePath) {
    return (

    );
  } else {
    return (
      <img
        srcSet={`${simplePurpleHouse15} 1.5x, ${simplePurpleHouse2} 2x, ${simplePurpleHouse3} 3x`}
        src={simplePurpleHouse1}
        alt="Primary Home"
        title="Primary Home"
        width="150"
        height="150"
      />
    );
  }
};

From what I've read it seems like the content-type: image/jpeg header should solve the problem, but Chrome still seems to see the mime-type as text/html despite the header I've set.

reference:
https://chromium.googlesource.com/chromium/src/+/master/services/network/cross_origin_read_blocking_explainer.md#Observable-CORB-impact-on-images

I also tried adding crossorigin="anonymous", but that did not solve the problem


问:
Are DryIoc scoped services tied to an event lifetime the right hammer for this nail?
We have a modular, plug-in based WPF Prism application that uses DryIoc as the IoC container. App.xmal.cs acts as our main composition root during application startup to bootstrap the IoC container and register services. Due to the decoupled, modular nature of the application, the main application (and therefore the composition root) doesn't have access to these types statically at compile time, rather they are discovered and registered dynamically at runtime.

Reflection-based assembly scanning is used to find all types implementing a custom interface, which are then created and called so that each project can register its own services with the IoC container during application startup (this is distinct from Prism's module and service resolution). The types are provided an IRegistrator instance to register their services. This approach has worked well for us so far, but now we have a new scenario, and are unsure how to proceed.

Let's simplify and assume we have the main application, App, and two projects, P1 and P2. App does not have a project reference to P1 or P2, and P1 and P2 don't know about each other either. Using the technique described above, P1 and P2 register their respective services during startup.

Throughout the lifetime of the application, a class in P1 periodically raises a Prism event that P2 subscribes to using Prism's IEventAggregator. The event payload contains some state that we want to store in P2 until the next event comes along and then we need to update the data. We created a class D (for data) in P2 to hold on to this data. D takes a dependency on IEventAggregator so that it can update the data whenever the aforementioned event is published.

P2 has a generic "lookup service" class, L<T> that requires an IEnumerable<T> at construction (which is sourced from pieces of the data stored on D) to lazily initialize private dictionaries for subsequent lookup operations. L<T> does not depend on the whole D class, but rather collection properties and sub-properties of D, i.e. no more than what it needs. The following pseudo-code mimics the approach of registering services in P2:

// Instantiated via reflection during app startup.
public class DryIocModule
{
    // Called during app startup.
    public void RegisterTypes(IRegistrator r)
    {
        r.Register<D>(Reuse.Singleton);
        r.RegisterDelegate(rc => new L<C>(rc.Resolve<D>().A.B.C), Reuse.Singleton);
        r.RegisterDelegate(rc => new L<Z>(rc.Resolve<D>().X.Y.Z), Reuse.Singleton);
    }
}
```

There are then various services that depend on an instance of L<T> to be injected in their constructor, and so on along the dependency graph.

Note that currently these services are registered with singleton lifetime. That's our "go-to" default for service lifetime, but is probably not the best option here (I'll come back to that).

The problem we have is, when the event is raised and the data on D is updated, all dependent services, like L<T> are now operating on stale data, and need to be updated themselves. Singleton lifetime sounds like a reasonable choice for D so that it can subscribe to the event and update its data/properties with the new event payload whenever the event is raised, but singleton does not seem like a good lifetime choice for L<T> because it will eventually be holding on to stale data the next time the event is raised. On the other hand, transient doesn't seem like a good lifetime choice either, because L<T> caches some data to optimize performance. We want to hold on to that cached data until the next time the event is raised and we have to re-establish the dictionaries that it contains.

It's like we want to scope the lifetime of L<T> to when the event is raised, where any requests for this service resolve to the same instance (to take advantage of the caching), but then have a new instance created the next time the event is raised.

Which leads me (finally) to my question... would DryIoc's scoped services be a solution to this problem? If so, how would we practically go about implementing this?

I've read some of the documentation on scoped services, but it's not clear to me what the correct/best approach is to take. Most of the examples I see assume you're in the composition root with access to the DryIoc Container and everything is known statically at compile time, which we don't have, although we could probably update our DryIocModule types to take a Container rather than an IRegistrator.

Injecting the Container into D (where we subscribe to the event) sounds a little like the service locator anti-pattern, and should be avoided, although we wouldn't be resolving services here, but registering them. It still doesn't feel right to be injecting the IoC container around the application though, if that's even what's required for defining scoped services that match the event's lifetime.

So, are DryIoc's scoped services a valid approach to this problem, and if so, how should they be implemented, or am I completely barking up the wrong tree, and there's a better/simpler solution?

Sorry for the long question, but wanted to try and provide as much relevant context as possible. Thanks in advance for any assistance.

Body:
We have a modular, plug-in based WPF Prism application that uses DryIoc as the IoC container. App.xmal.cs acts as our main composition root during application startup to bootstrap the IoC container and register services. Due to the decoupled, modular nature of the application, the main application (and therefore the composition root) doesn't have access to these types statically at compile time, rather they are discovered and registered dynamically at runtime.

Reflection-based assembly scanning is used to find all types implementing a custom interface, which are then created and called so that each project can register its own services with the IoC container during application startup (this is distinct from Prism's module and service resolution). The types are provided an IRegistrator instance to register their services. This approach has worked well for us so far, but now we have a new scenario, and are unsure how to proceed.

Let's simplify and assume we have the main application, App, and two projects, P1 and P2. App does not have a project reference to P1 or P2, and P1 and P2 don't know about each other either. Using the technique described above, P1 and P2 register their respective services during startup.

Throughout the lifetime of the application, a class in P1 periodically raises a Prism event that P2 subscribes to using Prism's IEventAggregator. The event payload contains some state that we want to store in P2 until the next event comes along and then we need to update the data. We created a class D (for data) in P2 to hold on to this data. D takes a dependency on IEventAggregator so that it can update the data whenever the aforementioned event is published.

P2 has a generic "lookup service" class, L<T> that requires an IEnumerable<T> at construction (which is sourced from pieces of the data stored on D) to lazily initialize private dictionaries for subsequent lookup operations. L<T> does not depend on the whole D class, but rather collection properties and sub-properties of D, i.e. no more than what it needs. The following pseudo-code mimics the approach of registering services in P2:

// Instantiated via reflection during app startup.
public class DryIocModule
{
    // Called during app startup.
    public void RegisterTypes(IRegistrator r)
    {
        r.Register<D>(Reuse.Singleton);
        r.RegisterDelegate(rc => new L<C>(rc.Resolve<D>().A.B.C), Reuse.Singleton);
        r.RegisterDelegate(rc => new L<Z>(rc.Resolve<D>().X.Y.Z), Reuse.Singleton);
    }
}

There are then various services that depend on an instance of L<T> to be injected in their constructor, and so on along the dependency graph.

Note that currently these services are registered with singleton lifetime. That's our "go-to" default for service lifetime, but is probably not the best option here (I'll come back to that).

The problem we have is, when the event is raised and the data on D is updated, all dependent services, like L<T> are now operating on stale data, and need to be updated themselves. Singleton lifetime sounds like a reasonable choice for D so that it can subscribe to the event and update its data/properties with the new event payload whenever the event is raised, but singleton does not seem like a good lifetime choice for L<T> because it will eventually be holding on to stale data the next time the event is raised. On the other hand, transient doesn't seem like a good lifetime choice either, because L<T> caches some data to optimize performance. We want to hold on to that cached data until the next time the event is raised and we have to re-establish the dictionaries that it contains.

It's like we want to scope the lifetime of L<T> to when the event is raised, where any requests for this service resolve to the same instance (to take advantage of the caching), but then have a new instance created the next time the event is raised.

Which leads me (finally) to my question... would DryIoc's scoped services be a solution to this problem? If so, how would we practically go about implementing this?

I've read some of the documentation on scoped services, but it's not clear to me what the correct/best approach is to take. Most of the examples I see assume you're in the composition root with access to the DryIoc Container and everything is known statically at compile time, which we don't have, although we could probably update our DryIocModule types to take a Container rather than an IRegistrator.

Injecting the Container into D (where we subscribe to the event) sounds a little like the service locator anti-pattern, and should be avoided, although we wouldn't be resolving services here, but registering them. It still doesn't feel right to be injecting the IoC container around the application though, if that's even what's required for defining scoped services that match the event's lifetime.

So, are DryIoc's scoped services a valid approach to this problem, and if so, how should they be implemented, or am I completely barking up the wrong tree, and there's a better/simpler solution?

Sorry for the long question, but wanted to try and provide as much relevant context as possible. Thanks in advance for any assistance.


问:
My Json file won't run in visual studio 2022
Added a json file to my project in visual studio and when I run it in the browser it gets an error.

I am still very new to visual studio and c# so I do not quite understand what is wrong.

My project is called Dinosaurs
This is the dinosaur.cs code

```<code>using System.Text.Json;
using System.Text.Json.Serialization;

namespace Dinosaurs.Models
{
    public class Dinosaur
    {
        public string DinoName { get; set; }
        public string Pronounced { get; set; }
        public string BriefDesc { get; set; }
        public string NameMeans { get; set; }
        public int LengthFt { get; set; }
        public int WeightLbs { get; set; }
        public int LivedYearsAgo { get; set; }
        public string ClassID { get; set; }
        public string PeriodID { get; set; }
        public override string ToString() => JsonSerializer.Serialize<Dinosaur>(this);
    }
}

</code>```

So this my models.cs code:

```<code>using System.Text.Json;
using System.Text.Json.Serialization;

namespace Dinosaurs.Models
{
    public class Dinosaur
    {
        public string DinoName { get; set; }
        public string Pronounced { get; set; }
        public string BriefDesc { get; set; }
        public string NameMeans { get; set; }
        public int LengthFt { get; set; }
        public int WeightLbs { get; set; }
        public int LivedYearsAgo { get; set; }
        public string ClassID { get; set; }
        public string PeriodID { get; set; }
        public override string ToString() => JsonSerializer.Serialize<Dinosaur>(this);
    }
}

</code>```

My services.cs code

```<code>using Dinosaurs.Models;
using System.Text.Json;

namespace Dinosaurs.Services
{
    public class JsonDinosaurService
    {

        public IWebHostEnvironment WebHostEnvironment { get; }

        private string JsonFileName
        {
            get { return Path.Combine(WebHostEnvironment.WebRootPath, "data", "dinosaurs.json"); }
        }

        //Constructor
        public JsonDinosaurService(IWebHostEnvironment webHostEnvironment)
        {
            WebHostEnvironment = webHostEnvironment;
        }

        //Get dinosaur method
        public IEnumerable<Dinosaur> GetDinosaurs()
        {
            using (var jsonFileReader = File.OpenText(JsonFileName))
            {
                return JsonSerializer.Deserialize<Dinosaur[]>(jsonFileReader.ReadToEnd(),
                    new JsonSerializerOptions
                    {
                        PropertyNameCaseInsensitive = true
                    });
            }
        }

    }
}
</code>```

My Startup.cs code

```<code>using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Dinosaurs.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Dinosaurs
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {

            services.AddRazorPages();
            services.AddTransient<JsonDinosaurService>();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
            });
        }
    }
}
</code>```

The page I am try to run it on is List.cshtml
This is the List.cshtmlcs code

```<code>using Dinosaurs.Models;
using Dinosaurs.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace Dinosaurs.Pages
{
    public class ListModel : PageModel
    {

        public JsonDinosaurService DinosaurService;

        public IEnumerable<Dinosaur> Dinosaurs { get; private set; }

        public ListModel(JsonDinosaurService dinosaurService)
        {
            DinosaurService = dinosaurService;
        }

        public void OnGet()
        {
            Dinosaurs = DinosaurService.GetDinosaurs();

        }is
h    }
}

</code>```
```<code>Is the List.cshtml code

@page
@model Dinosaurs.Pages.ListModel
@{
}

<h1>LIST OF DINOSAURS</h1>

@foreach (var dinosaur in Model.Dinosaurs)
{
    <h2>@dinosaur.DinoName</h2>
    <h2>@dinosaur.Pronounced</h2>
    <h2>@dinosaur.BriefDesc</h2>
    <h2>@dinosaur.NameMeans</h2>
    <h2>@dinosaur.LengthFt</h2>
    <h2>@dinosaur.WeightLbs</h2>
    <h2>@dinosaur.LivedYearsAgo</h2>
    <h2>@dinosaur.ClassID</h2>
    <h2>@dinosaur.PeriodID</h2>
}
</code>```

Body:
Added a json file to my project in visual studio and when I run it in the browser it gets an error.

I am still very new to visual studio and c# so I do not quite understand what is wrong.

My project is called Dinosaurs
This is the dinosaur.cs code

using System.Text.Json;
using System.Text.Json.Serialization;

namespace Dinosaurs.Models
{
    public class Dinosaur
    {
        public string DinoName { get; set; }
        public string Pronounced { get; set; }
        public string BriefDesc { get; set; }
        public string NameMeans { get; set; }
        public int LengthFt { get; set; }
        public int WeightLbs { get; set; }
        public int LivedYearsAgo { get; set; }
        public string ClassID { get; set; }
        public string PeriodID { get; set; }
        public override string ToString() => JsonSerializer.Serialize<Dinosaur>(this);
    }
}

So this my models.cs code:

using System.Text.Json;
using System.Text.Json.Serialization;

namespace Dinosaurs.Models
{
    public class Dinosaur
    {
        public string DinoName { get; set; }
        public string Pronounced { get; set; }
        public string BriefDesc { get; set; }
        public string NameMeans { get; set; }
        public int LengthFt { get; set; }
        public int WeightLbs { get; set; }
        public int LivedYearsAgo { get; set; }
        public string ClassID { get; set; }
        public string PeriodID { get; set; }
        public override string ToString() => JsonSerializer.Serialize<Dinosaur>(this);
    }
}

My services.cs code

using Dinosaurs.Models;
using System.Text.Json;

namespace Dinosaurs.Services
{
    public class JsonDinosaurService
    {

        public IWebHostEnvironment WebHostEnvironment { get; }

        private string JsonFileName
        {
            get { return Path.Combine(WebHostEnvironment.WebRootPath, "data", "dinosaurs.json"); }
        }

        //Constructor
        public JsonDinosaurService(IWebHostEnvironment webHostEnvironment)
        {
            WebHostEnvironment = webHostEnvironment;
        }

        //Get dinosaur method
        public IEnumerable<Dinosaur> GetDinosaurs()
        {
            using (var jsonFileReader = File.OpenText(JsonFileName))
            {
                return JsonSerializer.Deserialize<Dinosaur[]>(jsonFileReader.ReadToEnd(),
                    new JsonSerializerOptions
                    {
                        PropertyNameCaseInsensitive = true
                    });
            }
        }

    }
}

My Startup.cs code

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Dinosaurs.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Dinosaurs
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {

            services.AddRazorPages();
            services.AddTransient<JsonDinosaurService>();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
            });
        }
    }
}

The page I am try to run it on is List.cshtml
This is the List.cshtmlcs code

using Dinosaurs.Models;
using Dinosaurs.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace Dinosaurs.Pages
{
    public class ListModel : PageModel
    {

        public JsonDinosaurService DinosaurService;

        public IEnumerable<Dinosaur> Dinosaurs { get; private set; }

        public ListModel(JsonDinosaurService dinosaurService)
        {
            DinosaurService = dinosaurService;
        }

        public void OnGet()
        {
            Dinosaurs = DinosaurService.GetDinosaurs();

        }is
h    }
}

Is the List.cshtml code

@page
@model Dinosaurs.Pages.ListModel
@{
}

LIST OF DINOSAURS

@foreach (var dinosaur in Model.Dinosaurs)
{

@dinosaur.DinoName

@dinosaur.Pronounced

@dinosaur.BriefDesc

@dinosaur.NameMeans

@dinosaur.LengthFt

@dinosaur.WeightLbs

@dinosaur.LivedYearsAgo

@dinosaur.ClassID

@dinosaur.PeriodID

}


问:
TypeError: req.flash is not a function - Nodejs
I am trying to set up connect-flash to display messages. I have watched several tutorials but I'm still getting this error message " TypeError: req.flash is not a function " , you can see my app.use(flash()) is after session and before routes so I dont think that is the problem. (Im not using Passport module for this project).

If anyone can help I would appreciate it!

index.js

```<code>import express from 'express';
import router from './routes/index.js'
import path, {dirname, join} from 'path'
import { fileURLToPath } from "url"
import session from "express-session";
import MySQLStore from "express-mysql-session";
import pool from './database.js';
import multer from 'multer';
import flash from 'connect-flash';
import cookieParser from 'cookie-parser';

const app = express();

app.use(express.json({ extended: true }));
app.use(express.urlencoded({ extended: true }));

//VIEWS

const __dirname = dirname(fileURLToPath(import.meta.url))
app.set('view engine', 'ejs')
app.set('views', join(__dirname, 'views'))

//STATICS

app.use(express.static(join(__dirname, 'public')))

//MIDDLEWARES

app.use(session({
    secret: 'ZONA',
    resave: false,
    saveUninitialized: false,
    cookie: {maxAge: 60000},
    store: new MySQLStore({host: 'XXXX',
    database: 'hXXXX',
    user: 'XXXXX',
    password: 'XXXX'})
}));

app.use(cookieParser())
app.use(flash());

//ROUTES
app.use(router);

app.listen(process.env.PORT || 2000)
console.log('Server is listening on port', process.env.PORT || 2000);
</code>```

routes.js

```<code>import express from 'express';
import { Router } from 'express';
import path, {dirname, join} from 'path'
import { fileURLToPath } from "url"
import multer from 'multer';
import nodemailer from 'nodemailer';
import flash from 'connect-flash';
import pool from '../database.js';

const router = Router()

router.get('/anunciate', (req, res) => {
    res.render('anunciate.ejs', {message : req.flash('message')});
});

router.post('/stats', upload.single('uploaded_file'), function (req, res) {
    console.log(req.file, req.body)

    req.flash('message', 'Hemos recibido tu solicitud. Te contactaremos en breve.');
    res.redirect('/anunciate')

});

</code>```

anunciate.js

```<code><% if(message.lenght > 0) { %>
    <div class="container p-4">
      <div class="row">
        <div class="col-md-4 mx-auto">
            <div class="alert alert-success alert-dismissible fade show" role="alert">
              <strong style="font-family: Raleway">  <%= message %>
              </strong>
              <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>
        </div>
      </div>
    </div>
<% } %>
</code>```

Body:
I am trying to set up connect-flash to display messages. I have watched several tutorials but I'm still getting this error message " TypeError: req.flash is not a function " , you can see my app.use(flash()) is after session and before routes so I dont think that is the problem. (Im not using Passport module for this project).

If anyone can help I would appreciate it!

index.js

import express from 'express';
import router from './routes/index.js'
import path, {dirname, join} from 'path'
import { fileURLToPath } from "url"
import session from "express-session";
import MySQLStore from "express-mysql-session";
import pool from './database.js';
import multer from 'multer';
import flash from 'connect-flash';
import cookieParser from 'cookie-parser';

const app = express();

app.use(express.json({ extended: true }));
app.use(express.urlencoded({ extended: true }));

//VIEWS

const __dirname = dirname(fileURLToPath(import.meta.url))
app.set('view engine', 'ejs')
app.set('views', join(__dirname, 'views'))

//STATICS

app.use(express.static(join(__dirname, 'public')))

//MIDDLEWARES

app.use(session({
    secret: 'ZONA',
    resave: false,
    saveUninitialized: false,
    cookie: {maxAge: 60000},
    store: new MySQLStore({host: 'XXXX',
    database: 'hXXXX',
    user: 'XXXXX',
    password: 'XXXX'})
}));

app.use(cookieParser())
app.use(flash());

//ROUTES
app.use(router);

app.listen(process.env.PORT || 2000)
console.log('Server is listening on port', process.env.PORT || 2000);

routes.js

import express from 'express';
import { Router } from 'express';
import path, {dirname, join} from 'path'
import { fileURLToPath } from "url"
import multer from 'multer';
import nodemailer from 'nodemailer';
import flash from 'connect-flash';
import pool from '../database.js';

const router = Router()

router.get('/anunciate', (req, res) => {
    res.render('anunciate.ejs', {message : req.flash('message')});
});

router.post('/stats', upload.single('uploaded_file'), function (req, res) {
    console.log(req.file, req.body)

    req.flash('message', 'Hemos recibido tu solicitud. Te contactaremos en breve.');
    res.redirect('/anunciate')

});

anunciate.js

<% if(message.lenght > 0) { %>

                <%= message %>

              <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>

<% } %>


问:
MongoDB Concurrent Map Creating Duplicates issue
So reviewing existing similar questions I have been unable to find a working solution. I am experiencing the same issue as this thread.

Nodejs, MongoDB concurrent request creates duplicate record

I have a JS script, that has multiple functions. Within one of the functions it will check if in object exists in a collection, and update certain values, if it doesn't exist it will create the document with additional values.

The problem I am having is the concurrency function may have that same item multiple times causing duplicate documents to be created.

I have tried setting a in the Scheme a unique: true, without success.

Below is an example of the code I am running. I am try to keep the concurrency for speed if at all possible.

```<code>Txs = Array;
const promises = Txs.map(tx => {
   updateObject(tx)
}
const checkTxs = await Promise.all(promises)
return checkTxs
</code>```

and then the updateObject function is as so.

```<code>async function updateObject(tx) {
  model.findOne({ tx: tx }).then(async (tx) => {
   if(tx) {
     model.findOneAndUpdate({ tx: tx },
     {
       tx: tx,
     },
     { new: true }
 )
 } else {
  model.create({
   tx: tx
  })
 }
</code>```

I have also tried changing the .map to a forEach with no success. Is there any way I can keep concurrency without creating duplicates?

Body:
So reviewing existing similar questions I have been unable to find a working solution. I am experiencing the same issue as this thread.

Nodejs, MongoDB concurrent request creates duplicate record

I have a JS script, that has multiple functions. Within one of the functions it will check if in object exists in a collection, and update certain values, if it doesn't exist it will create the document with additional values.

The problem I am having is the concurrency function may have that same item multiple times causing duplicate documents to be created.

I have tried setting a in the Scheme a unique: true, without success.

Below is an example of the code I am running. I am try to keep the concurrency for speed if at all possible.

Txs = Array;
const promises = Txs.map(tx => {
   updateObject(tx)
}
const checkTxs = await Promise.all(promises)
return checkTxs

and then the updateObject function is as so.

async function updateObject(tx) {
  model.findOne({ tx: tx }).then(async (tx) => {
   if(tx) {
     model.findOneAndUpdate({ tx: tx },
     {
       tx: tx,
     },
     { new: true }
 )
 } else {
  model.create({
   tx: tx
  })
 }

I have also tried changing the .map to a forEach with no success. Is there any way I can keep concurrency without creating duplicates?