A federal judge in San Francisco, citing a "significant risk of harm" from the spread of the coronavirus, on Wednesday ordered a process for possible release of some of the more than 400 immigrants being held at two crowded California facilities.

U.S. District Judge Vince Chhabria said U.S. Immigration and Customs Enforcement "has not come close to achieving social distancing" needed to protect detainees from the virus at the Yuba County Jail in Marysville and Mesa Verde ICE Processing Center in Bakersfield.

Many of the immigrants, who are in civil administrative detention while awaiting immigration hearings, "are still sleeping in barracks-style dorms within arms-reach of one another," Chhabria wrote.

The judge issued a temporary restraining order requiring ICE to provide information, including medical conditions, about immigrants at the two facilities by noon Friday.

He said he will then conduct a two-week series of bail hearings, possibly with the assistance of several federal magistrates, to consider the release of individual detainees.

After that process, Chhabria said, he will hold a hearing on whether a preliminary injunction may be needed to require safe physical distancing among those who remain in detention.

The judge said any release orders for individual detainees will take into account medical conditions, whether the person is likely to appear for immigration hearings and whether the person has a criminal record.

He ordered ICE to provide each immigrant's name, age, any health vulnerabilities and any criminal records.

The fact that ICE did not already have such a list, six weeks after Gov. Gavin Newsom ordered a statewide shutdown, "speaks volumes about where the safety of these people falls on ICE's list of priorities," Chhabria wrote.

Chhabria acted in a lawsuit filed last week by seven immigrants on behalf of all those being detained at the two facilities. In the same order on Wednesday, Chhabria provisionally certified the lawsuit as a class action on behalf of all the detainees.

The judge wrote that "the conditions of confinement do not merely threaten detainees; they also threaten facility staff, not to mention the greater community whose health is put at risk by the congregation of large groups in cramped spaces."

The lawsuit alleges that immigrants are unsafely crowded together in dormitory rooms with bunk beds, shared bathrooms and cafeteria lines, and are not given adequate materials for sanitation and hygiene.

At the time of a hearing held by Chhabria on Tuesday, ICE had no reports of COVID-19 cases at the two facilities, but it had tested only two people there, the judge noted.

ICE spokesman Jonathan Moor said the agency does not comment on pending litigation.

But he said that in general at ICE facilities, "comprehensive protocols are in place for the protection of staff and detainee patients, including the appropriate use of personal protective equipment in accordance with Centers for Disease Control guidance."

Moor said that both the Yuba County Jail and the Mesa Verde ICE Processing Center have reduced their populations to approximately 70 percent of what they were in January.

He said since April 17, detainees at the Mesa Verde center have been given surgical masks, which are replaced three times per week.

The seven immigrants who filed the original lawsuit are from El Salvador, Guatemala, Kenya, Mexico and Vietnam.